Listview question

romill

Member
Licensed User
Longtime User
Hey,

I'm making a reference app, and I want to use list view to make it. I need to make it so the initial screen is a list of topics. And upon clicking one topic it will bring up some subtopics. Clicking one of those will bring up a wall of text describing whatever.

How can I do this?

Thanks
 

romill

Member
Licensed User
Longtime User
Okay, so I decided to go an alternate route and load the strings from an array.

I have these strings in an array
B4X:
aa(0) = "A"
   aa(1) = "B"
   aa(2) = "C"
   aa(3) = "D"
   aa(4) = "E"
   aa(5) = "F"
   aa(6) = "G"

And then I'm using this to call them...
B4X:
ListView1.Initialize("ListView1")
   ListView1.ScrollingBackgroundColor = Colors.Transparent
   ListView1.SingleLineLayout.ItemHeight = 100dip
    ListView1.SingleLineLayout.Label.TextSize = 20
    ListView1.SingleLineLayout.Label.TextColor = Colors.red
   ListView1.SingleLineLayout.Label.Gravity = Gravity.CENTER
   ListView1.FastScrollEnabled = True
        startv(0,6)

Here is the startv function
B4X:
Sub startv(start As Int, endint As Int)
   For i = start To endint 
      ListView1.AddSingleLine(aa(i))
      i = i + 1
   Next
End Sub

Now the strings "A" "C" "E" and "G" are displayed.

What's going on here? It's skipping every other string. How do I fix this? My code looks fine..

EDIT:
I just tried using...

B4X:
aa(0) = "A"
   aa(2) = "B"
   aa(4) = "C"
   aa(6) = "D"
   aa(8) = "E"
   aa(10) = "F"
   aa(12) = "G"
with startv(0,12) and it worked fine. This seems rather inefficient. Wasting every other array space and all.
 
Last edited:
Upvote 0

stevel05

Expert
Licensed User
Longtime User
You are incrementing the loop counter manually, as well as it doing it itself.

Sent from my Hero using Tapatalk
 
Upvote 0
Top