Make item go beneath the previous entry listview

sarim123

Member
Licensed User
Longtime User
Hello, how would i make an item go beneath the previous entry in a list view listview. Right now when you add something the listview items are add in the order of
3
2
1

and i am trying add the list view items in the order of
1
2
3
This is what i have now
B4X:
Sub btnSubmit_Click
   If edtText.Text <> "" Then
      lstText.InsertAt(0, edtText.Text)
      FillListView
      edtText.Text = ""
   Else
      Msgbox("No entry !", "ERROR")
   End If
End Sub

Sub FillListView
   ltvTexts.Clear
   For i = 0 To lstText.Size - 1
      ltvTexts.AddSingleLine(lstText.Get(i))
   Next
End Sub
 

stevel05

Expert
Licensed User
Longtime User
The problem you have is that you are inserting each item at index 0, and expecting them to list in the order you added them.

You can use lstText.add(edtText.Text) which will append each item to the end of the list, which should then be displayed in the correct order.

If you are just displaying them, you don't need to keep the extra list, you could add them directly to the list view.
 
Last edited:
Upvote 0
Top