Android Question Display and maintain a sorted list

udg

Expert
Licensed User
Longtime User
Hi all,

I feel I'm missing the obvious, but what component will you use to display a short sorted list and keep it sorted when adding/deleting items ?

My first thought went to list + listview coupled with type declaration to manage all the infos related to an item. Then I thought that list + customlistview could have been more flexible.

But both listview and clv doesn't let me simply select-only an item (short of programming their itemclick methods) so I could later use a few buttons to decide which action to apply.
Another option could be to attach a pop-up menu to the itemclick event; I don't know.

A few more details to help you suggest me for the best:

- the list will contain at most 10/15 items
- the user will add new item compiling a very short form then hit an "Add" button to insert that new item in its proper position in the list
- the user should be able to modify or delete an existing item (so the idea to simply select it)
- available space is at minimum so scrolling will be a must

I understand that I described a mini-CRUD system where a table will fit ok, but won't a table be too much for such simple situation?

So, what will you use in such a situation? TIA.
 
Last edited:

azzam223

Active Member
Licensed User
Longtime User
hi my friend about list you can create custom type for example

B4X:
type listvalue(value as string,index as int)

to delete item create loop to search about the item by it value and also same loop in second sub to update value by remove it from list then add again with insert sub also you can use insert sub to add value in select position
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Thank you @azzam223 , that's close to what I came up as my first thought.
I'm now reading about context menus (and other kind of menus in general) to learn something new and possibly useful as a solution to my problem.

udg
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Thanks @Erel,

I've used that in the past so I know what to do. But what if I'd ike to open a context menu on clv'' item click like you did for text selection not so far ago?
Can you help me understand that code and modify it for clv? TIA
 
Upvote 0

udg

Expert
Licensed User
Longtime User
OK, thanks. Probably I'll go with a popup menu.
Just for my knowledge, what in your code does start the context menu? I mean, I can't see an explict call to menu creation so it should be something linked to text selection but how? TIA
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…