Android Question InputListAsync(data,"请选择要编辑的月份:",0,False) List not available?Hope to get help, thank you!

guandjy

Member
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand("select_yuefenkongzhi",Array("是"))
Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
If j.Success Then
req.HandleJobAsync(j, "req")
Wait For (req) req_Result(res As DBResult)
req.PrintTable(res)
Dim data As List
data.Initialize
For Each row() As Object In res.Rows
Dim val1 As String = row(res.Columns.Get("yuefenkongzhi"))
data.Add(Array(val1))
Next
InputListAsync(data,"请选择要编辑的月份:",0,False)
Wait For InputList_Result (Index As Int)
If Index <> DialogResponse.CANCEL Then
b=data.Get(Index)
End If
 

guandjy

Member
lQDPDhtAWhSogKTNAm7NBCSwjksANsCbelACOht43IA8AA_1060_622.jpg
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
How to convert the data array in the database into characters?
Maybe this example will help you:
B4X:
    Dim data As List
    data.Initialize
    data.Add(Array ("Paris", "France", "Europe"))
    data.Add(Array ("Kyiv", "Ukraine", "Europe"))
    data.Add(Array ("Cairo", "Egypt", "Africa"))
    data.Add(Array ("Beijing", "China", "Asia"))
    data.Add(Array ("Santiago", "Chili", "America"))

   Dim l As List
    l.Initialize   
    For i=0 To data.Size-1
        Dim r(3) As String =data.Get(i)
        Dim sb As StringBuilder
        sb.Initialize       
        For j=0 To r.Length-1
            If j=r.Length-1 Then
                sb.Append(r(j))
            Else
                sb.Append(r(j)).Append(",")
            End If
        Next
        l.Add(sb.ToString)
    Next
    InputListAsync(l, "Select a place", 0, False)
    Wait For InputList_Result (Index As Int)
    If Index <> DialogResponse.CANCEL Then
        Log("Selected place: " & l.Get(Index))
    End If
You need to put your code inside code tags. It will look a lot better and more readable.
The output will be this:
1647715595266.png
 
Last edited:
Upvote 0

aeric

Expert
Licensed User
Longtime User
Just remove Array
data.Add(val1)

B4X:
    Dim req As DBRequestManager = CreateRequest
    Dim cmd As DBCommand = CreateCommand("SELECT_yuefenkongzhi", Array("是"))
    Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
    If j.Success Then
        req.HandleJobAsync(j, "req")
        Wait For (req) req_Result(res As DBResult)
        req.PrintTable(res)
        Dim data As List
        data.Initialize
        For Each row() As Object In res.Rows
            Dim val1 As String = row(res.Columns.Get("yuefenkongzhi"))
            data.Add(val1)
        Next
        
        InputListAsync(data, "请选择要编辑的月份:", 0, False)
        Wait For InputList_Result (Index As Int)
        If Index <> DialogResponse.CANCEL Then
            Dim b As String = data.Get(Index)
            Log(b)
        End If
    End If
 
Upvote 0

guandjy

Member
Maybe this example will help you:
B4X:
    Dim data As List
    data.Initialize
    data.Add(Array ("Paris", "France", "Europe"))
    data.Add(Array ("Kyiv", "Ukraine", "Europe"))
    data.Add(Array ("Cairo", "Egypt", "Africa"))
    data.Add(Array ("Beijing", "China", "Asia"))
    data.Add(Array ("Santiago", "Chili", "America"))

   Dim l As List
    l.Initialize  
    For i=0 To data.Size-1
        Dim r(3) As String =data.Get(i)
        Dim sb As StringBuilder
        sb.Initialize      
        For j=0 To r.Length-1
            If j=r.Length-1 Then
                sb.Append(r(j))
            Else
                sb.Append(r(j)).Append(",")
            End If
        Next
        l.Add(sb.ToString)
    Next
    InputListAsync(l, "Select a place", 0, False)
    Wait For InputList_Result (Index As Int)
    If Index <> DialogResponse.CANCEL Then
        Log("Selected place: " & l.Get(Index))
    End If
You need to put your code inside code tags. It will look a lot better and more readable.
The output will be this:
View attachment 126760
Thank you for your plan. It's great. It works perfectly
 
Upvote 0

guandjy

Member
只需删除数组
数据。添加(val1)

B4X:
 Dim req As DBRequestManager = CreateRequest
    Dim cmd As DBCommand = CreateCommand("SELECT_yuefenkongzhi", Array("是"))
    等待 (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
    如果 j.Success 那么
        req.HandleJobAsync(j, "req")
        等待 (req) req_Result(res As DBResult)
        req.PrintTable(res)
        将数据变暗为列表
        数据.初始化
        For Each row() As Object In res.Rows
            Dim val1 As String = row(res.Columns.Get("yuefenkongzhi"))
            数据。添加(val1)
        下一个
      
        InputListAsync(data, "请选择要编辑的月份:", 0, False)
        等待 InputList_Result(索引为 Int)
        If Index <> DialogResponse.CANCEL Then
            Dim b As String = data.Get(Index)
            日志(b)
        万一
 
[/QUOTE]

Just remove Array
data.Add(val1)

B4X:
    Dim req As DBRequestManager = CreateRequest
    Dim cmd As DBCommand = CreateCommand("SELECT_yuefenkongzhi", Array("是"))
    Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
    If j.Success Then
        req.HandleJobAsync(j, "req")
        Wait For (req) req_Result(res As DBResult)
        req.PrintTable(res)
        Dim data As List
        data.Initialize
        For Each row() As Object In res.Rows
            Dim val1 As String = row(res.Columns.Get("yuefenkongzhi"))
            data.Add(val1)
        Next
       
        InputListAsync(data, "请选择要编辑的月份:", 0, False)
        Wait For InputList_Result (Index As Int)
        If Index <> DialogResponse.CANCEL Then
            Dim b As String = data.Get(Index)
            Log(b)
        End If
    End If
Thank you, but it still works after deletion. The solution upstairs can be solved
 
Upvote 0
Top