Android Question Search For Listview - Sloved

My New Pr.png


B4X:
Sub Globals
    Private ListView1 As ListView
    Dim l As List
    Private Button1 As Button
    Private EditText1 As EditText
End Sub

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")
   
   
    l.Initialize
    ListView1.AddSingleLine2("Mostafa",1)
    l.Add("Mostafa")
    ListView1.AddSingleLine2("Ali",2)
    l.Add("Ali")
    ListView1.AddSingleLine2("Mohsen",3)
    l.Add("Mohsen")
    ListView1.AddSingleLine2("Hassan",4)
    l.Add("Hassan")
    ListView1.AddSingleLine2("Milad",5)
    l.Add("Milad")
    ListView1.AddSingleLine2("Reza",6)
    l.Add("Reza")
    ListView1.AddSingleLine2("Riva",7)
    l.Add("Riva")
    ListView1.AddSingleLine2("Hiva",8)
    l.Add("Hiva")
    ListView1.AddSingleLine2("Hamid",9)
    l.Add("Hamid")
   

   
   
    #Region Data Sting List Item
    ListView1.SingleLineLayout.Label.TextSize = 16
    ListView1.SingleLineLayout.Label.TextColor = Colors.White
    ListView1.SingleLineLayout.Label.Gravity = Gravity.CENTER
    #End Region
End Sub

B4X:
Sub ListView1_ItemClick (Position As Int, Value As Object)
    If Position = 0 Then
        ToastMessageShow("بخش اول",False)
    Else If Position = 1 Then
        ToastMessageShow("بخش دوم",False)
    Else If Position = 2 Then
        ToastMessageShow("بخش سوم",False)
    Else If Position = 3 Then
        ToastMessageShow("بخش چهارم",False)
    Else If Position = 5  Then
        ToastMessageShow("بخش پنجم",False)
    Else If Position = 5 Then
        ToastMessageShow("بخش ششم",False)
    Else If Position = 6 Then
        ToastMessageShow("بخش هفتم",False)
    Else If Position = 7 Then
        ToastMessageShow("بخش هشتم",False)
    Else If Position = 8 Then
        ToastMessageShow("بخش نهم",False)
    End If
End Sub

B4X:
Sub Button1_Click
    ListView1.Clear
    For i=0 To l.Size-1
        Dim g As String
        g=l.Get(i)
        If g.Contains(EditText1.Text)=True Then
            ListView1.AddSingleLine(g)
        End If
    Next
    If ListView1.Size=0 Then
        ToastMessageShow("Not here",False)
    End If
End Sub

I need a Listveiw with search Button... ?
 
Last edited:

Mahares

Expert
Licensed User
Longtime User
Upvote 0
Upvote 0
Top