Android Question http getstring in autocomplete setitems

Discussion in 'Android Questions' started by Kiran Raotole, Aug 18, 2018.

  1. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    I got http.getstring == [{"place_return":",'','a place','b place','c place'"}] like this

    and i have to insert it into autocomplete.setitem()
    I tried like this ::
    Dim p As JSONParser
    p.Initialize(Job.GetString)
    Dim list1 As List
    list1 = p.NextArray
    Dim map1 As Map
    map1 = list1.Get(0)
    AutoCompleteEditText1.SetItems(map1.Get("place_return"))

    but it not works log show error = java.lang.ClassCastException: anywheresoftware.b4a.objects.collections.Map$MyMap cannot be cast to java.util.List

    what is solution?
     
  2. npsonic

    npsonic Active Member Licensed User

    AutoCompleteEditText method SetItems need List.
     
  3. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    Yeah, I got it. But it is in json object, is there any to convert this json object into list
     
  4. npsonic

    npsonic Active Member Licensed User

    You can always create your own parser for the job.
     
    Last edited: Aug 19, 2018
  5. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    Ok. Take this like.
    I have a list in a string.
    Example a = "' ','a city','b city','c city'"
    I want to use this string in AutoCompleteEditText1.SetItems
    so i write it as
    AutoCompleteEditText1.SetItems(Array As String(a))
    but show only one string.
    I want each city in autocomplete
     
  6. npsonic

    npsonic Active Member Licensed User

    Code:
    Dim items As List
    items.Initialize
    Do While a.Contains(",")
        a = a.SubString(a.IndexOf(
    "'") + 1)
        items.Add(a.SubString2(
    0, a.IndexOf("'")))
        a = a.SubString(a.IndexOf(
    ",") + 1)
    Loop
    a = a.SubString(a.IndexOf(
    "'") + 1)
    items.Add(a.SubString2(
    0, a.IndexOf("'")))
    AutoCompleteEditText1.SetItems(items)
     
    Erel likes this.
  7. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    Thanks a lot. It works perfect.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice