B4J Question [ABMaterial] List like CustomListView

yiankos1

Well-Known Member
Licensed User
Longtime User
Hello,

I would like to create x number of custom items in a list, like we are doing in CLV. After that, when clicking a button/label/etc... onClick method is called and through Sender object you can get the specific child of that CLV.

I saw the example of infinite page that fits most like a CLV, but i can't figure out how to handle the onClick method of a random card's button.

Is there something that i am missing? or is there any other control/helper that fits more like a CLV?

Thank you for your time.
 
Last edited:

MichalK73

Well-Known Member
Licensed User
Longtime User
See my thread:
https://www.b4x.com/android/forum/threads/abmaterial-universal-page-for-application-settings.131563/

I'm building a MAP site, but to the point.
Each item on the list page has a different 'id' built from a parameter: this can be the idx of the database.
E.g. for checkbox
B4X:
                        Dim input2 As ABMCheckbox
                        Dim split() As String = Regex.Split("=",linie.Get(i+1))
                        input2.Initialize(page, "inpCheck_"&split(0), s0, False,"")
                        If split(1)="1" Then
                            input2.State=True
                        Else
                            input2.State = False
                        End If
                        page.Cell(row,1).AddComponent(input2)

In the function that handles appearing events on the page
'Sub Page_ParseEvent(Params As Map)'.
I have support for ABMCheckbox
B4X:
    If eventName.StartsWith("inpcheck") And eventName.Contains("clicked") Then
        objekt=""
        Dim split() As String = Regex.Split("_", eventName)
        If split.Length > 2 Then
            For i=1 To split.Length-2
                objekt=objekt&"_"& split(i)
            Next
            objekt = objekt.SubString2(1,objekt.Length)
            eventName = split(0)&"_"&split(split.Length-1)
        Else
            objekt = split(1)
            eventName = split(0)&"_"&split(2)
        End If
    End If
The way it works is that it pulls from id_paramater, the parameter itself, sets it to a global variable and then calls the ABMCheckbox handler functions
B4X:
Sub inpcheck_Clicked(Target As String)
    Dim check As ABMCheckbox = page.Component("inpcheck_"&objekt)
    If check.State Then
        ChangeConfig(objekt, "1")
    Else
        ChangeConfig(objekt, "0")
    End If
    LogDebug("check - "&objekt&" "&check.State)
End Sub

In this way, you can handle any large ABMList list on the page elements within it.
 
Upvote 1

yiankos1

Well-Known Member
Licensed User
Longtime User
See my thread:
https://www.b4x.com/android/forum/threads/abmaterial-universal-page-for-application-settings.131563/

I'm building a MAP site, but to the point.
Each item on the list page has a different 'id' built from a parameter: this can be the idx of the database.
E.g. for checkbox
B4X:
                        Dim input2 As ABMCheckbox
                        Dim split() As String = Regex.Split("=",linie.Get(i+1))
                        input2.Initialize(page, "inpCheck_"&split(0), s0, False,"")
                        If split(1)="1" Then
                            input2.State=True
                        Else
                            input2.State = False
                        End If
                        page.Cell(row,1).AddComponent(input2)

In the function that handles appearing events on the page
'Sub Page_ParseEvent(Params As Map)'.
I have support for ABMCheckbox
B4X:
    If eventName.StartsWith("inpcheck") And eventName.Contains("clicked") Then
        objekt=""
        Dim split() As String = Regex.Split("_", eventName)
        If split.Length > 2 Then
            For i=1 To split.Length-2
                objekt=objekt&"_"& split(i)
            Next
            objekt = objekt.SubString2(1,objekt.Length)
            eventName = split(0)&"_"&split(split.Length-1)
        Else
            objekt = split(1)
            eventName = split(0)&"_"&split(2)
        End If
    End If
The way it works is that it pulls from id_paramater, the parameter itself, sets it to a global variable and then calls the ABMCheckbox handler functions
B4X:
Sub inpcheck_Clicked(Target As String)
    Dim check As ABMCheckbox = page.Component("inpcheck_"&objekt)
    If check.State Then
        ChangeConfig(objekt, "1")
    Else
        ChangeConfig(objekt, "0")
    End If
    LogDebug("check - "&objekt&" "&check.State)
End Sub

In this way, you can handle any large ABMList list on the page elements within it.
Thank you very much for your answer.

I have to admit that it is a very clever approach!

Tomorrow, I will give it a try and I am gonna hit that 'Mark as solution' button.

Thanks again.
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Upvote 1
Top