B4J Question [ABMaterial] List Clicked

MichalK73

Well-Known Member
Licensed User
Longtime User
Hello.
After switching to a 4.3 version of the project, ABMList Clicked stopped working. Update libraries 4.25 to 4.3 done. page.NeedsList = True is.
How to solve it ?
 

MichalK73

Well-Known Member
Licensed User
Longtime User
OKAY.
I added
B4X:
Sub Page_ParseEvent(Params As Map)

    Dim eventName As String = Params.Get("eventname")
    Dim eventParams() As String = Regex.Split(",",Params.Get("eventparams"))
    Log("Event->"&eventName)
and got the result:
Event-> 1_clicked when I click on the item in the list
where I am:
B4X:
Dim lista As ABMList
lista.Initialize (page, "lista", ABM.COLLAPSE_EXPANDABLE, "lista")
page.Cell (3.1) .AddComponent (lista)

B4X:
Sub lista_Clicked(ItemId As String)
    Dim t As String = DBMh.SQLSelectSingleResult2("select title from faq where idx=?", Array As String(ItemId))
    Dim v As String = DBMh.SQLSelectSingleResult2("select value from faq where idx=?", Array As String(ItemId))
    Dim okno As ABMModalSheet = page.ModalSheet("AddModal")
    Dim tyt As ABMLabel = okno.Content.Component("tyt")
    Dim tresc As ABMEditor = okno.Content.Component("edit")
    tyt.Text = t
    tresc.SetHTML(v)
    tyt.Refresh
    tresc.Refresh
    If page.IsDesktop Then
        tyt.FontSize("34px")
    Else
        tyt.FontSize("14px")
    End If
    page.ShowModalSheet("AddModal")
End Sub
So is it bad?
 
Upvote 0

MichalK73

Well-Known Member
Licensed User
Longtime User
I followed the trail that @alwaysbus gave, checking adding items to the list.
B4X:
    Dim list As ABMList = page.Component("lista")
    Dim wynik As List
    wynik = DBMh.SQLSelect("select * from faq")
    For i =0 To wynik.Size-1
        Dim m As Map = wynik.Get(i)
        Dim pos As Int = i+1
        list.AddItemWithTheme(m.Get("idx"),tytul(pos&". "&m.Get("title")),"poz")
    Next
    list.Refresh

B4X:
Sub tytul(value As String) As ABMLabel
    Dim a As ABMLabel
    a.Initialize(page,"1",value, ABM.SIZE_H5,True,"pozycja")
    a.Clickable = True
    If page.IsDesktop Then
        a.FontSize("24px")
    Else
        a.FontSize("14px")
    End If
    Return a
End Sub

And something like that does not work. However, I noticed that I gave there as id label "1" which did not bother with version 4.25.
After changing to:

B4X:
Sub tytul(value As String) As ABMLabel
    Dim a As ABMLabel
    a.Initialize(page,value,value, ABM.SIZE_H5,True,"pozycja")
    a.Clickable = True
    If page.IsDesktop Then
        a.FontSize("24px")
    Else
        a.FontSize("14px")
    End If
    Return a
End Sub

B4X:
Event->lista_clicked

Everything is moving and working. But what effect does id_label have on the ABMList I do not know?
 
Upvote 0

MichalK73

Well-Known Member
Licensed User
Longtime User
B4X:
Sub tytul(value As String) As ABMLabel
    Dim a As ABMLabel
    a.Initialize(page,"1",value, ABM.SIZE_H5,True,"pozycja")
    a.Clickable = False
    If page.IsDesktop Then
        a.FontSize("24px")
    Else
        a.FontSize("14px")
    End If
    Return a
End Sub

It works too. In version 4.25 as was a.Clickable = True it worked.
The most important thing is that the problem is solved.
Thank you for the tip.
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
Just out of curiosity...

Isn't it faster for a single call to the database better than running two whilst returning different fields in the same query? And then parse that query result? Or the impact is rather insignificant?

B4X:
Dim t As String = DBMh.SQLSelectSingleResult2("select title from faq where idx=?", Array As String(ItemId))
    Dim v As String = DBMh.SQLSelectSingleResult2("select value from faq where idx=?", Array As String(ItemId))
 
Upvote 0

MichalK73

Well-Known Member
Licensed User
Longtime User
Just so I wrote the code to make it easier. I did not consider the speed, because the base is still locally where the server on SSD.
 
Upvote 0
Top