Adding content from file to Listview with Check

GMan

Well-Known Member
Licensed User
Longtime User
I want to add a set of strings from a saved file to a listview with check boxes, where some or all can be selected and want to read out then the checked strings and write them in another file.

B4X:
   Dim TR13 As TextReader 
   TR13.Initialize(File.OpenInput(File.DirInternal,"Filelist.lst"))
   MyPlanListView1.AddSingleLine(TR13.ReadLine)
   TR13.Close

With this code only 1 line is inserted, with other Add...-methods, too.
How can i count the number of strings (max. 10) in the FileList.lst until the end ?

Regards
 
Last edited:

GMan

Well-Known Member
Licensed User
Longtime User
This code i figured out, but works only in parts:

B4X:
Dim TR13 As TextReader 
TR13.Initialize(File.OpenInput(File.DirInternal,"Filelist.lst"))

Dim Listi1 As List
Dim ListiEintrag As String
Listi1.Initialize
 For I = 1 To 10
' TR13.ReadLine(Listi1)
  Listi1.Add(TR13.ReadLine)
    MyPlanListView1.AddSingleLine(Listi1)
 Next
TR13.Close

But with this code in the 1st entry of the Listview line1 from file is written, in the 2nd Line1 and Line2, in the 3rd Line1, Line2 and Line3 etc.
 
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
Thx a lot, Erel - things are often easier as i think ;-):icon_clap:


Is there an easier/simplier way to create for those entries a checkbox for each as the Class from Informatix ?

Must not be a check box, a visible feedback (like the touched row is marked by another color or so) in any way is enough.

Tried something out, but didn't work:
B4X:
Sub  MyPlanListView1_ItemLongClick (Position As Int, Value As Object)
        MyPlanListView1.SingleLineLayout.Background = True
   MyPlanListView1.SetSelection (Position)
   MyPlanListView1.GetItem(Position)
   MyPlanListView1.GetItem(Colors.Blue)
End Sub

This code changes the color of the whole Listview:
B4X:
    Dim ItemPosition As Int
   MyPlanListView1.SetSelection (Position)
   ItemPosition = Position
   MyPlanListView1.Color = Colors.blue
 
Last edited:
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
I Solved it by simply adding 10 checkboxes to the layout.
When saving, the buttons are cheked if they re check and if, the value of this line is written to the logfile.

 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…