Android Question Suggestions for a dropdown list to show/pick a value but saving the values id to database

kgf

Member
Licensed User
I am building an app for data entry/editing and have a sqlite database table with a foreign key to another table with the related information

On loading a view I need an text input to show the lookup value of an id in a field and if it is edited show the new value, and then save the new id.

So I am looking for the best option for a input box dropdown to pick 1 item from up from up to 100 items and then store the id for that chosen value. Any suggestions for the best type of input to use. Also not sure what would be the most efficient way to create the list data for the input. Have been looking at lists, maps and custom objects but not sure which would be best to use. Have been looking for ideas through the forum but still not sure what is the best combination of input type and list data to use.

Being able to display more than one column in the dropdown list would be useful as well.

Thanks
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
I am building an app for data entry/editing and have a sqlite database table with a foreign key to another table with the related information

On loading a view I need an text input to show the lookup value of an id in a field and if it is edited show the new value, and then save the new id.

So I am looking for the best option for a input box dropdown to pick 1 item from up from up to 100 items and then store the id for that chosen value. Any suggestions for the best type of input to use. Also not sure what would be the most efficient way to create the list data for the input. Have been looking at lists, maps and custom objects but not sure which would be best to use. Have been looking for ideas through the forum but still not sure what is the best combination of input type and list data to use.

Being able to display more than one column in the dropdown list would be useful as well.

Thanks

I think tableview might be a good option:
https://www.b4x.com/android/forum/threads/class-tableview-supports-tables-of-any-size.19254/

RBS
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
If you're creating the control, you can create a custom type that contains all of the identifying information you require, in addition to the listview entry itself if necessary for reference.
 
Upvote 0

kgf

Member
Licensed User
If you're creating the control, you can create a custom type that contains all of the identifying information you require, in addition to the listview entry itself if necessary for reference.
Thanks, will try a custom type, something new for me. Based on this https://www.b4x.com/android/forum/threads/listview-reading-second-line.7059/#post40547 am I right to assume that I can display certain items on the list from the type on the list, but return other items from the type on click etc.
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
I think so, if I understand what you're asking. I needed a similar control for a project for a while back, it's basically a listview with an option button with the list item. You give the item an ID and an event is raised when they select a different option. I've attached an example project of the control to this post, perhaps you can gain some insight from going through it.
 

Attachments

  • optionlistview.zip
    101.1 KB · Views: 231
Upvote 0

kgf

Member
Licensed User
I think so, if I understand what you're asking. I needed a similar control for a project for a while back, it's basically a listview with an option button with the list item. You give the item an ID and an event is raised when they select a different option. I've attached an example project of the control to this post, perhaps you can gain some insight from going through it.
Thanks for the example, only a week into B4A so good to see how things can be done in different ways. So I could add any ID value to the foList.AddItem( ID as string,.. and retrieve it on selected, and the listview would be sorted by the order added not the ID.
 
Upvote 0
Top