B4J Question xCustomListView, Click Event not raised

mw71

Active Member
Licensed User
Longtime User
hi, i need a Listview. I use xCustomListView.

Call the Sub with.
B4X:
    Services.ExecuteListView(lbl_vomBerg.Text,Starter.Liste_Berge,ListView_vBerg)

In this called sub i add the Values:
B4X:
Sub ExecuteListView(varSearch As String, Tabelle As List, Listview_Service As CustomListView)
    Loggen.cl("Execute List View, Main: " & varSearch)
    Dim varCols, varColsUp As String

    Listview_Service.Clear

    For i = 0 To Tabelle.Size - 1    'simple begrenzung mit min funktioniert nicht, da auch die Berge drauf zugreifen
        varCols = Tabelle.Get(i)
        varColsUp=varCols.ToUpperCase
        If varColsUp.Contains(varSearch.ToUpperCase) Then Listview_Service.AddTextItem(varCols,varCols)
    Next
End Sub

it works, but the Click Event is not rised??
 

LucaMs

Expert
Licensed User
Longtime User
You are adding a text to the cCLV, not selecting one; this would trigger the event.

BTW, xCLV does not allows to select an item by code (my xCLV yes ☺).

If enough, you can do:
B4X:
If varColsUp.Contains(varSearch.ToUpperCase) Then
    Listview_Service.AddTextItem(varCols,varCols)
    Listview_Service_ItemClick(Listview_Service.Size - 1, varCols)
End If

Private Sub Listview_Service_ItemClick (Index As Int, Value As Object)
   Log(Index & tab & Value)
End Sub
 
Last edited:
Upvote 0

stevel05

Expert
Licensed User
Longtime User
The event will be raised in the Module or class that the ListView is defined in. Where have you added the ItemClick sub?
 
Upvote 0

mw71

Active Member
Licensed User
Longtime User
Hello,

my question was too unspecific.

The CLV is "coupled" to a text field.
The user types in this text field, the sub (ExecuteListView, call every text field change) looks for matching entries and enters them into the CLV.
The user should now click on a text field displayed in the CLV and this should be write into the text field.
Unfortunately it does not work. When the user clicks on the CLV Text field to select, the click event is not called.

The List View is add via the Designer.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
BTW, xCLV does not allows to select an item by code (my xCLV yes ☺).
There is no "selection" in the default xCLV. You can use this class to add this feature: https://www.b4x.com/android/forum/t...ion-modes-for-xcustomlistview.114364/#content

The user types in this text field, the sub (ExecuteListView, call every text field change) looks for matching entries and enters them into the CLV.
You can use B4XDialog + B4XSearchTemplate for this feature (it is more sophisticated and will provide better performance).

What is the CLV event name? Where is the sub that handles the ItemClick event? Post its code.
 
Upvote 0

mw71

Active Member
Licensed User
Longtime User
Hi,

B4XDialog + B4XSearchTemplate do that what i need, but i need it on the Main Page.

I have add the xCLV with the Designer and create the Members:
Private ListView_vBerg As CustomListView
Private Sub ListView_vBerg_ItemClick (Index As Int, Value As Object)

the Code inside is simple:
B4X:
Private Sub ListView_vBerg_ItemClick (Index As Int, Value As Object)
    Log("ListView_vBerg_ItemClick") ''<<== dont fire
    
    lbl_vomBerg.Text=Value
    ListView_vBerg.AsView.Visible=False
End Sub
 
Upvote 0

mw71

Active Member
Licensed User
Longtime User
rigth, also a Code Modul.
there Sub's i call at Start of the Programm. I can move it to other Code Muduls, but for me it is more convenient to arrange the code this way
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
it's a Code Module named "Service"
Switch to a Service or a Class instantiated in a Service.
Code modules can not use any Events. That´s the point better not to use them.
 
Upvote 0

mw71

Active Member
Licensed User
Longtime User
Service in B4J??, i mean that exist only in B4A

In the code modules is no waiting for events or other. I use them e.g. to generate lists or for other "services".
 
Upvote 0

mw71

Active Member
Licensed User
Longtime User
thank you @LucaMs, it works.

now i must found a way to hide (visible=false) the Listview if i leave the lbl_vomBerg without select one frome the Listview
(with Select all o.k.)
 
Upvote 0
Top