Android Question ScrollView2D Index

tariqyounis

Member
Licensed User
Longtime User
Hello All;
I have a button loaded in ScrollView2D. I would like to get the index of the button I press. in CustomListView I used to get the index by this code

get the index:
Dim i As Int = clvItems.GetItemFromView(Sender)

any advice!
 

Brian Dean

Well-Known Member
Licensed User
Longtime User
The usual way to do this is to put a value in the button.Tag, and then read it from the "Sender" in a common click handler, much as you describe in your example ...
B4X:
Sub button_Click
    Dim btn As Button = Sender
    Dim index As Int = btn.tag
    xui.MsgboxAsync("Button number" & index, "Button clicked")   
End Sub
 
Upvote 0

tariqyounis

Member
Licensed User
Longtime User
The usual way to do this is to put a value in the button.Tag, and then read it from the "Sender" in a common click handler, much as you describe in your example ...
B4X:
Sub button_Click
    Dim btn As Button = Sender
    Dim index As Int = btn.tag
    xui.MsgboxAsync("Button number" & index, "Button clicked")  
End Sub
it worked!!!
thank you very much...
 
Upvote 0
Top