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

Discussion in 'Android Questions' started by busmatic, Oct 10, 2019 at 5:28 AM.

  1. busmatic

    busmatic Member Licensed User

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

    Regards
     
  2. DonManfred

    DonManfred Expert Licensed User

  3. busmatic

    busmatic 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
     
  4. mangojack

    mangojack Well-Known Member Licensed 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.

    Code:
    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
     
    Erel likes this.
  5. busmatic

    busmatic Member Licensed User

    Thanks, mangojack

    Your code worked :)
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice