Android Question B4XTable How do I change the color of a row ?

Situ LLC

Active Member
Licensed User
Hi, using a table created with B4XTable how can I change the color of a specific row.

Regards
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Situ LLC

Active Member
Licensed User
DonManfred,

Thanks for answering

I do not need to use the "B4XTable1_CellClicked" event, what I need is to change the color of a row where it is not clicked, example in a table that has 10 rows, I want to change the color of row No. 5.

Note: in this thread to implement the code for Sub B4XTable1_CellClicked and it gives me these errors

SelectedRows.Add (RowId) <--- does not exist
SetRowColor (Index, Selected) <--- does not exist
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
The reason @DonManfred supplied that link was so you could download the sample project and ADAPT the code to suit your needs. (see Sub SetRowColor)


1. You will have to set the Selection Color of the Table in Designer to Transparent.
2. You will have to set up a method of recoloring previously selected rows to default color.

B4X:
    Dim RowIndex As Int = 4 'the 5th Table Row
Dim SelectionColor As Int = 0xFF009DFF
For Each c As B4XTableColumn In B4XTable1.VisibleColumns
    Dim pnl As B4XView = c.CellsLayouts.Get(RowIndex + 1) '+1 because of the header
    pnl.Color = SelectionColor
Next
 
Upvote 0

Situ LLC

Active Member
Licensed User
Thanks, mangojack

Your code worked :)
 
Upvote 0
Top