Android Question how to populate data into spinner from mysql

alfian01

Member
Licensed User
good morning every one,
i have question, how to populate data into spinner from mysql, not from sql lite.
thank's
 

ronell

Well-Known Member
Licensed User
sample code to retrieve data in json format and populate spinner
B4X:
Dim job As HttpJob
    job.Initialize("",Me)
    job.Download(url)
    ProgressDialogShow2("Please wait...",False)
    Wait For (job) JobDone(j As HttpJob)
    
    ProgressDialogHide
            
    If j.Success Then
                        
        Dim res As String
                        
        res = j.GetString.Trim 

         Dim parser As JSONParser
         parser.Initialize(res)
 
         Dim users As List

         users = parser.NextArray

         
        If users .Size = 0 Then
     
            MsgboxAsync("no result","")
        Else

        For i = 0 To users .Size - 1
         Dim user_map As Map
         user_map = users .Get(i)

         dim name as string
       
        name = user_map .Get("user_name")

        
        Spinner1.Add(name)

        Sleep(0)
 
        Next

        end if

     
        Else
        MsgboxAsync("Can't connect to server, Please try again","")
        
       
    End If
    j.release
 

alfian01

Member
Licensed User
sample code to retrieve data in json format and populate spinner
B4X:
Dim job As HttpJob
    job.Initialize("",Me)
    job.Download(url)
    ProgressDialogShow2("Please wait...",False)
    Wait For (job) JobDone(j As HttpJob)
  
    ProgressDialogHide
          
    If j.Success Then
                      
        Dim res As String
                      
        res = j.GetString.Trim

         Dim parser As JSONParser
         parser.Initialize(res)
 
         Dim users As List

         users = parser.NextArray

       
        If users .Size = 0 Then
   
            MsgboxAsync("no result","")
        Else

        For i = 0 To users .Size - 1
         Dim user_map As Map
         user_map = users .Get(i)

         dim name as string
     
        name = user_map .Get("user_name")

      
        Spinner1.Add(name)

        Sleep(0)
 
        Next

        end if

   
        Else
        MsgboxAsync("Can't connect to server, Please try again","")
      
     
    End If
    j.release
thank's to erel and ronell for your answer, i was try your answer and succeded.
 
Top