B4J Question Tableview selected cell question.

Mikelgiles

Active Member
Licensed User
Longtime User
I need to know the selected cell or selected column on a tableview. I have looked extensively in the forum and have not found a answer. I know that B4J always knows the SelectedRow and that the selected cell can get highlited so I visually know what column (cell) is selected. But I need code that will tell me what column is selected. I thought maybe .SelectedColumn but if so I have not found it. Is there any simple way to get it with Java?

I am thinking that maybe jTableViewExtended would be a solution but I assume that jTableViewExtended only works for B4J and not for B4A and B4I. The reason I want to use B4J is because I need the code to also work on B4A and B4I.
 

jmon

Well-Known Member
Licensed User
Longtime User
to retrieve which column / cell is selected:
B4X:
Sub AppStart (Form1 As Form, Args() As String)
    '..    
    tv1.SingleCellSelection = True
End Sub

Sub tv1_SelectedCellChanged (RowIndex As Int, ColIndex As Int, Cell As Object)
    Log(RowIndex)
    Log(ColIndex)
    Log(Cell)
End Sub
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
just 2 small comments.

The UI code in B4J, B4A and B4I is not compatible with each other, that means:

only works for B4J and not for B4A and B4I.

This is also true for Tableview, what it is fully compatible is most of the Non UI, stringutils, types, arrays, etc. There are some work on creating tables in B4A that are very good, so i think even when the UI code is not compatible, you are still covered

For the second comment

if you write sub + space + tab you will be presented with a list, click in any of the items and you will be shown with each of the events belonging to the item just like this one.

B4X:
Sub tv1_SelectedCellChanged (RowIndex As Int, ColIndex As Int, Cell As Object)
 
Upvote 0

Mikelgiles

Active Member
Licensed User
Longtime User
to retrieve which column / cell is selected:
B4X:
Sub AppStart (Form1 As Form, Args() As String)
    '..   
    tv1.SingleCellSelection = True
End Sub

Sub tv1_SelectedCellChanged (RowIndex As Int, ColIndex As Int, Cell As Object)
    Log(RowIndex)
    Log(ColIndex)
    Log(Cell)
End Sub

Wonderful solution. So simple! Now I need to figure out why I missed it so totally. I did look at SelectedCellChanged but my assumption on what it did was totally wrong. I need to take a look at it again and try to figure out why I missed it so bad. Thanks very much jmon!
 
Upvote 0
Top