Listview not showing Value onclick

bishmedia

Member
Licensed User
Longtime User
I have adapted some code kindly helped by 'gregwa' but i have now come across some issues which i didnt contemplate at the start....

1) When clicking an item in the list the message box is blank??
2) The list needs unique vales and sorting??

Any boffins out there wanna tell/show me how... :-(

B4X:
Sub Process_Globals
    '-----------------------------
    Dim WebSearch As HttpJob
    '-----------------------------
    Dim parser As SaxParser
End Sub

Sub Globals
    Dim SiteToRead = "http://www.bishmedia.co.uk/default/Apps/xmldata.xml"
   Dim ListView1 As ListView
   Dim Title As String
   Dim ItemSelected As String
    Dim bandname As String   
End Sub

Sub Activity_Create(FirstTime As Boolean)
    WebSearch.Initialize("WebSearch",Me)
    parser.Initialize
    WebSearch.Download(SiteToRead)
   Activity.LoadLayout("listviewtest")
End Sub

Public Sub JobDone (Job As HttpJob)
    '-----------------------------
    Dim j As InputStream
    '-----------------------------
    If Job.Success = True Then
        j = Job.GetInputStream
        parser.Parse(j, "parser")
    End If
End Sub

Sub Parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
   If parser.Parents.IndexOf("result") > -1 Then
      If Name = "bandName" Then
         Title = Text.ToString
            ListView1.AddSingleLine2(Title, bandname)         
      End If
   End If      
End Sub

Sub ListView1_ItemClick (Position As Int, Value As Object)   
   ItemSelected = Value
   Msgbox(ItemSelected,"Clicked on")      
End Sub
 

bishmedia

Member
Licensed User
Longtime User
Ah yes i can see that now, thanks :)

Would you suggest putting the results in a variable() and sorting or is there a list view option for unique/sorting??
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
A ListView is just that, a list view, if you need to sort the data then you could add the parsed data to a List and do something like:
B4X:
MyList.SortCaseInsensitive(True)

and then populate the ListView; if you want more complex operations like unique, sort, etc, then save the data to a SQLite database.

I'm just throwing you some ideas.
 
Upvote 0

bishmedia

Member
Licensed User
Longtime User
Sadly Sql isn't an option for me at the moment.
How would i populate the listview if i did the following??

B4X:
Sub Parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
Dim List1 As List
List1.Initialize
   If parser.Parents.IndexOf("postc") > -1 Then
      If Name = "postcode" Then
         Title = Text.ToString
         List1.Add(Title)         
      End If
   End If   
   
   List1.SortCaseInsensitive(True)
   
End Sub
 
Upvote 0
Top