Android Question Tableview.SelectedRow

GGS

Member
Licensed User
Longtime User
I need to retrieve the row number currently selected in a table when the user clicks a button. Multi-select is not enabled so I just need one row (not a list). It seems like this should be very simple, but I can't figure it out. Is there something like this:
B4X:
Dim a as Int
a = TableView.SelectedRow

Any help is greatly appreciated.

Thanks,
GGS
 

klaus

Expert
Licensed User
Longtime User
Three solutions:
1)
Add this routine in the Table class:
B4X:
'Returns the selected row, or the first selected row in MultiSelect mode
Sub getSelectedRow
  Return SelectedRows.Get(0)
End Sub
And in your code a =TableView.SelectedRow

2)
B4X:
Dim SelRows as List
SelRows = TableView.SelectedRows
a = SelRows.Get(0)

3) Add a TableView_CellClick event routine in your code and handle The SelctedRow yourself.

Not tested, but should work.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…