How to use db1.txt,db2.txt,... for the same widget

Theera

Well-Known Member
Licensed User
Hi all,
refer the old thread,
If I split db.txt to be db(1).txt,db(2).txt,...,and add a new button for select db(n).txt order to widget could bring to use. How to do? Please give me a example .
P.S. 1.) db.txt is big file,but I can split to be groups.
2.) I try coding myself,but have problem about spinner
Best Regards
Theera
 
Last edited:

Yafuhenk

Active Member
Licensed User
Hi Theera,

The Spinner behaves very strange indeed.
Maybe you can work with a simple button and an inputlist.
I use this is my app as well.

Not everything in your post is clear to me but I hope this is what you are looking for:



Henk
 

Attachments

  • EditedManyDB.zip
    8.9 KB · Views: 118
Upvote 0

klaus

Expert
Licensed User
I would do it that way, your code modified.
B4X:
Sub Process_Globals
   Dim dbSelected As String : dbSelected = "db1.txt"
End Sub

Sub Globals
    'Declare parameters for Layout1
    Dim Panel1 As Panel
    Dim Spinner1 As Spinner
    Dim label1 As Label
    Dim listview1 As ListView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout1")
    Panel1.Visible=True
    Spinner1.AddAll(Array As String("db1.txt","db2.txt"))
    Spinner1_ItemClick(0, "db1.txt")
End Sub

Sub Spinner1_ItemClick (Position As Int, Value As Object)
    dbSelected = Value

    If File.Exists(File.DirAssets,dbSelected) Then
        listview1.Clear
        Dim Reader1 As TextReader
        If Reader1.IsInitialized = False Then
            Reader1.Initialize(File.OpenInput(File.DirAssets,dbSelected))
        End If
        Dim line As String
        line=Reader1.ReadLine
        Do While line <> Null
            listview1.AddSingleLine(line)
            line=Reader1.ReadLine
        Loop
        Reader1.Close
    End If           
End Sub
Best regards.
 

Attachments

  • MannyDB1.zip
    8.5 KB · Views: 133
Upvote 0

Theera

Well-Known Member
Licensed User
Thank you for kind of you,YAFUHENK and Klaus
Best Regards
Theera
 
Last edited:
Upvote 0
Top