Android Question [Solved]I just need to pick something off a listview.

RMarra

Member
Licensed User
I've asked before for help on this but I think I was not specific enough on what I want, so I got recommendations that did not address my need.

I have a button on the activity. When it is pressed, I want a listview to appear on the screen and wait for a selection to be made. Once the selection is made, I want the listview to go away and the data returned from it be used in the remainder of the button_click routine.

for example:
B4X:
Sub Button_Click
<do stuff>
<Popup listview>
<take response from listview and do more stuff>
end sub
I have tried an activity module for the listview, but it does not appear until after all the code in the button_click has executed.

I tried putting an invisible panel on the activity and making it visible in the button_click. It just doesn't happen.

I tried writing code to build the listview on the fly and that was a disaster.

I think my VB experience may be blinding me to the subtleties of android programming.
 

Cableguy

Expert
Licensed User
Use a Panel, load the list view to it, show when needed, pass the value back to the calling activity...
I dont recommend you to return to the button click, use this event to "launch" the panel with the listview, and return to another sub to continue your logic.

(EDIT) I just saw that you have already tried it… but beware of Z-Order… are you sure the panel didn't show? or was it just laying behind something else?
 

rraswisak

Active Member
Licensed User
you can try this code:

B4X:
Sub Button1_Click
  ... open list view dialog
  Wait For ListWasSelected
  ... code after selection
End Sub

Sub ListView1_ItemClick (Position As Int, Value As Object)
   ToastMessageShow("Your selection is: " & Value,False)
   ... close list dialog
   CallSubDelayed(Me,"ListWasSelected")
End Sub
 

RMarra

Member
Licensed User
I went with creating an activity and moving the "code after selection" to the activity_resume

Thanks for your help
 
Top