Android Tutorial List with two columns and a checkbox

Hello,

I have a TabHost which holds 4 tabs.
I want to have a list with two columns and a checkbox for each line in the list on the forth tab of the TabHost.

How can I do it? In case it's not possible - how can I do it without the checkboxes?

Thank you for your help,
Elad.
 

CyclopDroid

Well-Known Member
Licensed User
Longtime User
Hi,
Exist a way, using this example of a list with checkboxes, for position the scrollview to the end of the list?

Thanks
 

CyclopDroid

Well-Known Member
Licensed User
Longtime User
Thanks, but doese not work :(
I would that the line should reach on the last entered value (in questoa test on "Word100").


B4X:
Sub Process_Globals
End Sub
Sub Globals
    Dim ScrollView1 As ScrollView
    Dim lstChecks As List
    Dim height As Int
    height = 20dip
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Test for list into ScrollView
    ScrollView1.Initialize(0)
    Dim pnl As Panel
    pnl = ScrollView1.Panel
    Activity.AddView(ScrollView1, 0, 0, 100%x, 50%y)
    lstChecks.Initialize
  
    For i = 1 To 100
        Dim chk As CheckBox
        chk.Initialize("")
  
        chk.Text = "Word" &  i
        chk.Enabled=False
      
        chk.Gravity=Gravity.LEFT
        lstChecks.Add(chk)
        Dim lbl1 As Label
        lbl1.Initialize("")
        lbl1.Text =  i
        lbl1.Gravity = Gravity.RIGHT
        chk.TextColor=Colors.White
        lbl1.TextColor=Colors.Green
      
          pnl.AddView(chk, 0, height * (i - 1), 120dip, height)
        pnl.AddView(lbl1, 150dip, height * (i - 1), 150dip, height)
      
    Next
    pnl.height = lstChecks.Size * height
    ScrollView1.ScrollPosition = height * 100
    'ScrollView1.ScrollPosition = height * pnl.NumberOfViews-1
End Sub


... it could be because is declare:

B4X:
pnl = ScrollView1.Panel
?
 

CyclopDroid

Well-Known Member
Licensed User
Longtime User
Wait!... Ok Thanks you. I had insert a DoEvents and it Work ;)

B4X:
...
...
...
    Next
    pnl.height = lstChecks.Size * height
    DoEvents
  ScrollView1.ScrollPosition = height * pnl.NumberOfViews-1
End Sub
 

thanos

Member
Licensed User
Longtime User
This is not supported by ListView.
For a simple list with checkboxes you can use InputMultiList dialog.
However in your case I recommend you to use a ScrollView.
Here is an example of a list with checkboxes:
Hello.
I know that the thread is old, but it remail useful.
This part of code is not working in v4:
B4X:
lstChecks.Add(chk)
and
B4X:
chk = lstProducts.Get(i)
Which is the correct method in order to add the checkbox in the listview and get the current checkbox?
Regards
 
Last edited:
Top