B4J Question [SOLVED][ABMaterial] ABMTable all selected rows after loading

PatrikCavina

Active Member
Licensed User
Longtime User
When i load rows with theme in ABMTable all of it are selected.
My code:

MyPage.BuildTheme sub:
B4X:
public Sub BuildTheme()
    ' start with the base theme defined in ABMShared
    theme.Initialize("pagetheme")
    theme.AddABMTheme(ABMShared.MyTheme)

    theme.AddInputTheme("inputauto")
    theme.Input("inputauto").AutoCompleteZDepth = ABM.ZDEPTH_1
  
    theme.AddTableTheme("ttt")
    theme.Table("ttt").AddCellTheme("cc1")
    theme.Table("ttt").Cell("cc1").BackColor = ABM.COLOR_RED
    theme.Table("ttt").AddCellTheme("cc2")
    theme.Table("ttt").Cell("cc2").BackColor = ABM.COLOR_AMBER
  
End Sub

MyPage.ConnectPage Sub:
B4X:
public Sub ConnectPage()         
    '    connecting the navigation bar
    ABMShared.ConnectNavigationBar(page)

    Dim tb As ABMTable
    tb.Initialize(page, "tbl", False, False, True, "ttt")
    tb.SetHeaders(Array As String("Head1", "Head2", "Head3"))
    Dim alt As Boolean = True
    For i = 0 To 10
        Dim row As List
        Dim rowT As List
        row.Initialize
        rowT.Initialize
        For j = 0 To 2
            Dim st As String = Rnd(0,1000)
            row.Add(st)
            If alt Then rowT.Add("cc1") Else rowT.Add("cc2")
        Next
        tb.AddRow("", row)
        tb.SetRowThemes(rowT)
        alt = Not(alt)
    Next
    page.Cell(1, 1).AddComponent(tb)

 
    ' refresh the page
    page.Refresh
 
    ' Tell the browser we finished loading
    page.FinishedLoading
    ' restoring the navigation bar position
    page.RestoreNavigationBarPosition 

End Sub

ABMShared.BuildTheme sub:
B4X:
' build methods for ABM objects
Sub BuildTheme(themeName As String)
    MyTheme.Initialize(themeName)
  
    ' the page theme
    MyTheme.Page.BackColor = ABM.COLOR_WHITE 
  
End Sub

And result when page is loaded is this:
Immagine.png

If i set isInteractive = true in table initialize method, and I click on one row then rows themes appears:
upload_2018-10-8_9-28-55.png

How can i load data in table without they will selected?
Thanks in advance.
 

Harris

Expert
Licensed User
Longtime User
How can i load data in table without they will selected?
The "isinteractive" (true) means rows are selectable.
When set to false, it appears cell themes are not applied - and it uses the default "selected" background color theme. This does not mean they are all selected - just the color makes them appear that way - but nothing is selectable in this state (it is not interactive - for display purposes only!).

Try:
theme.Table("ttt").BackColor = ABM.COLOR_YELLOW
to see if that affects row color when isinteractive is false....


This section covers ABMTable use, but does not delve into the interactive flag since most devs create tables to interact with - view, add, edit, delete...

https://www.b4x.com/android/forum/threads/abmaterial-for-dummies-beginner-lessons.88346/#post-561010
 
Upvote 0

PatrikCavina

Active Member
Licensed User
Longtime User
I set IsInteractive = false and i set theme.Table("ttt").BackColor = ABM.COLOR_YELLOW.
This is new code:
B4X:
public Sub BuildTheme()
    ' start with the base theme defined in ABMShared
    theme.Initialize("pagetheme")
    theme.AddABMTheme(ABMShared.MyTheme)

    theme.AddInputTheme("inputauto")
    theme.Input("inputauto").AutoCompleteZDepth = ABM.ZDEPTH_1
    
    theme.AddTableTheme("ttt")
    theme.Table("ttt").BackColor = ABM.COLOR_YELLOW '<------------- +
    theme.Table("ttt").AddCellTheme("cc1")
    theme.Table("ttt").Cell("cc1").BackColor = ABM.COLOR_RED
    theme.Table("ttt").AddCellTheme("cc2")
    theme.Table("ttt").Cell("cc2").BackColor = ABM.COLOR_AMBER
    
End Sub

public Sub ConnectPage()           
    '    connecting the navigation bar
    ABMShared.ConnectNavigationBar(page)

    Dim tb As ABMTable
    tb.Initialize(page, "tbl", False, False, False, "ttt")
    tb.SetHeaders(Array As String("Head1", "Head2", "Head3"))
    Dim alt As Boolean = True
    For i = 0 To 10
        Dim row As List
        Dim rowT As List
        row.Initialize
        rowT.Initialize
        For j = 0 To 2
            Dim st As String = Rnd(0,1000)
            row.Add(st)
            If alt Then rowT.Add("cc1") Else rowT.Add("cc2")
        Next
        tb.AddRow("", row)
        tb.SetRowThemes(rowT)
        alt = Not(alt)
    Next
    page.Cell(1, 1).AddComponent(tb)

    
    ' refresh the page
    page.Refresh
    
    ' Tell the browser we finished loading
    page.FinishedLoading
    ' restoring the navigation bar position
    page.RestoreNavigationBarPosition   

End Sub

But the result is the same

upload_2018-10-9_10-3-32.png


And if i set isSelectable = true the result is this:

ezgif.com-optimize.gif
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
This looks like a bug (all lines appear to be active at startup), but for the time being you could set the table to interactive = false, and use the ActiveBackColor instead of the backcolor in the theme:

B4X:
theme.AddTableTheme("ttt")
theme.Table("ttt").AddCellTheme("cc1")
theme.Table("ttt").Cell("cc1").ActiveBackColor = ABM.COLOR_RED
theme.Table("ttt").AddCellTheme("cc2")
theme.Table("ttt").Cell("cc2").ActiveBackColor = ABM.COLOR_AMBER

Please add it to the feedback app so I can look for a fix before the next release.
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
This looks like a bug
There are no bugs in ABM (you would not sit well with that) - just a lack of knowledge to make it function properly. ;)

@PatrikCavina - review the dummies tutorial (again) to gain your base understanding.
Since uid's are critical - I should have stressed this fact in the tut... Sorry. I shall update it...

Posts like this help to "fill in the holes" for beginners - where we who are familiar just take these things for granted.

EDIT: Updated this issue in (dummies) Tips & Tricks...

Thanks
 
Last edited:
Upvote 0
Top