Why my widget add only 1 item into spinner?

Theera

Expert
Licensed User
Longtime User
Hi all,
Please help me look for my error. Why my widget add only 1 item into spinner?

Best Regards
Theera
 
Last edited:

klaus

Expert
Licensed User
Longtime User
Replace this code:
B4X:
    Dim line As String
        line = Rd1.ReadLine 
        Do While line <> Null AND line <> ""
            Dim lstA,LstB As List
            lstA.Initialize
            LstB.Initialize
            Dim str() As String
            str = Regex.Split(",", line)
            lstA.Add(str(0))
            LstB.Add(str(1))
        
            line = Rd1.ReadLine    
        Loop
            
        Rd1.Close
        ProductList.AddAllAt(0,lstA)
        PriceList.AddAllAt(0,LstB)
by this one:
B4X:
    ProductList.Clear
        PriceList.Clear
        Dim line As String
        line = Rd1.ReadLine 
        Do While line <> Null AND line <> ""
            Dim str() As String
            str = Regex.Split(",", line)
            ProductList.Add(str(0))
            PriceList.Add(str(1))
        
            line = Rd1.ReadLine    
        Loop
        Rd1.Close
You initialize istA and lstB in the loop so you have only one item in there.
There is no need to have these intermediate lists.

Best regards.
 
Upvote 0

Theera

Expert
Licensed User
Longtime User
I'm not understand about myself

Thank you for kind of you again.
I have ever written as same as your code.But it's shown only last one of items in spinner. Therefore I must use Productlst.AddAllAt(0,lstA) again.
Best Regards
Theera
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
What exactly have you done ?
Have you replaced the code as I suggested you in my previous post ?

Attached you find the modified project of your first post.
Isn't this waht you want ?

Best regards.
 

Attachments

  • test1.zip
    6.2 KB · Views: 153
Upvote 0
Top