ListView

omaroski

Member
Licensed User
Longtime User
I'm working with this view but when i click an item the code inside ItemClick or ItemLongClick is not executed.

Can you help me?

B4X:
#Region Module Attributes
   #FullScreen: False
   #IncludeTitle: True
#End Region

Sub Process_Globals
   
End Sub

Sub Globals

   Dim Contatti As Contacts2
   Dim Rubrica As List
   Dim edtName As EditText
   Dim ContattoSingolo As Map
   Dim ListView1 As ListView
   Dim ListaABC As List
   
End Sub

Sub Activity_Create(FirstTime As Boolean)
   
   Activity.LoadLayout("RicercaContatto")
   ListView1.Initialize("Rubrica")
    Activity.AddView(ListView1, 0, 100, 480, 600)

End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub


Sub btnSearch_Click
   ListView1.Clear
   Rubrica = Contatti.FindByName(edtName.Text, False, True, False)
   For i = 0 To Rubrica.Size -1
   Dim Contatto(Rubrica.Size) As Contact
   Contatto(i) = Rubrica.Get(i)
   Dim PhoneNo As Map
   PhoneNo = Contatto(i).GetPhones
   For p = 0 To PhoneNo.Size -1   
   ListView1.AddTwoLines2(Contatto(i).DisplayName, PhoneNo.GetKeyAt(p), i)
   Next
   Next
   
End Sub

Sub ListView1_ItemClick (Position As Int, Value As Object)
   Log("click")
End Sub

Sub ListView1_ItemLongClick (Position As Int, Value As Object)
   Log("long click")
End Sub
 

mc73

Well-Known Member
Licensed User
Longtime User
In activity_create you initialize a listView telling it to call subs starting with "Rubrica". Thus, you should have
B4X:
Sub Rubrica_ItemClick (Position As Int, Value As Object)
    Log("click")
End Sub

Sub Rubrica_ItemLongClick (Position As Int, Value As Object)
    Log("long click")
End Sub

instead of listView1_itemclick etc.

I would recommend you go through Klaus' beginner's guide. It has nothing to do with being a beginner or an experienced programmer, it has to do with conventions used in this IDE.
 
Upvote 0
Top