Initializing Multiple ListViews Causing Java Runtime Exceptions

Highwinder

Active Member
Licensed User
Longtime User
Hello fellow gurus! I come groveling to the masters to solve a stange problem:

I am trying to initialize a series of ListViews (16 of them). I am initializing all but one of them invisibly (only the first one is visible/enabled). Depending on what the user does, each of the listviews enable/disable and become visible/invisible to quickly alternate between them (to produce a live menu feel, like navigating a tree).

Example of how I'm initializing the ListViews:

'ListView1
ListView1.Initialize("ListView1")
Activity.AddView(ListView1, 0, 0, 100%x, 100%y)
ListView1.SingleLineLayout.Label.TextSize = 14
ListView1.SingleLineLayout.Label.TextColor = Colors.White
ListView1.SingleLineLayout.Label.Gravity = Gravity.CENTER
ListView1.Visible = True
ListView1.Enabled = True

ListView1.AddSingleLine("Menu Option 1")
ListView1.AddSingleLine("Menu Option 2")

'ListView2
ListView2.Initialize("ListView2")
Activity.AddView(ListView2, 0, 0, 100%x, 100%y)
ListView2.SingleLineLayout.Label.TextSize = 14
ListView2.SingleLineLayout.Label.TextColor = Colors.White
ListView2.SingleLineLayout.Label.Gravity = Gravity.CENTER
ListView2.Visible = False
ListView2.Enabled = False

ListView2.AddSingleLine("Menu Option 1")
ListView2.AddSingleLine("Menu Option 2")

And so on...

However, upon running the app, I get this as the 5th ListView is being initialized:

"java.lang.RuntimeException: Don't call setOnClickListener for an AdapterView. You probably want setOnItemClickListener instead."

All the (B4A) code I'm using for initializing my ListViews is identical, and I have poured over it many times to ensure that my code is not the problem (initialized and set up exactly the same way as the ListViews before it which work just fine).

Is there some kind of limit to the number of ListViews that can be initialized for a single activity?

I've just hit a brick wall with this. Help! :sign0085::BangHead:
 

mc73

Well-Known Member
Licensed User
Longtime User
sure you declared listview5 as a listview? and in the initialize, did you set "listview5"?
 
Upvote 0

Highwinder

Active Member
Licensed User
Longtime User
I'll upload

I'll upload something. It can't be my actual project, but I'll upload an example with the same problem.
 
Upvote 0

Highwinder

Active Member
Licensed User
Longtime User
Interesting

Found the problem:

This is what I had:

Sub ListView5_Click (Position As Int, Value As Object)


This is what it was SUPPOSED to be:

Sub ListView2Premortal_ItemClick (Position As Int, Value As Object)

Solved.
 
Last edited:
Upvote 0

Highwinder

Active Member
Licensed User
Longtime User

Yeah yeah, I know.

I was checking MY code, which is what the debugger and java errors were pointing to - not the IDE's automatically inserted code, which the debugger and java errors were NOT pointing to.

:sign0094:
 
Upvote 0
Top