Cara membuat Android Listview pada B4A

Create B4A Projecty
G to designer, addview ListView
 
generate member
 
This will add
Sub Globals
 'These global variables will be redeclared each time the activity is created.
 'These variables can only be accessed from this module.

 Private ListView1 As ListView
End Sub

Sub ListView1_ItemClick (Position As Int, Value As Object)
 
End Sub

Sub ListView1_ItemLongClick (Position As Int, Value As Object)
 
End Sub
save your Layout and load it
Sub Activity_Create(FirstTime As Boolean)
 'Do not forget to load the layout file created with the visual designer. For example:
 Activity.LoadLayout("Layout1")

End Sub
Add your code
Sub Activity_Create(FirstTime As Boolean)
 'Do not forget to load the layout file created with the visual designer. For example:
 Activity.LoadLayout("Layout1")
 ListView1.AddSingleLine2("Sunday", 1)
 ListView1.AddSingleLine2("Monday", 2)
 ListView1.AddSingleLine2("Tuesday", 3)
 ListView1.AddSingleLine2("Wednesday", 4)

End Sub

Sub ListView1_ItemClick (Position As Int, Value As Object)
 Log("You Clicked :" & Position & "-" & Value)
End Sub

Komentar