Event when Spinner is clicked

padvou

Active Member
Licensed User
Longtime User
In previous version I could declare a sub for example Spinner1_Click
The current version throws an error. Is there away to fire an event when a spinner is clicked? (Not the item clicked)
 

padvou

Active Member
Licensed User
Longtime User
java.lang.RuntimeException: java.lang.RuntimeException: Don't call setOnClickListener for an AdapterView. You probably want setOnItemClickListener instead
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I don't see that behavior, it's working correctly here. Can you post your code? zip the project from the IDE if possible.
 
Upvote 0

padvou

Active Member
Licensed User
Longtime User
Are you using the 2.50 version?
In 2.22 it was working.
Try and add a spinner from the designer, generate a member so that it adds "Dim spinner1 as spinner"
Then manually add a
Sub spinner1_Click

End Sub
You get the error...
I 'll try and export the project
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
The correct sub signature should be:

B4X:
Sub Spinner1_ItemClick (Position As Int, Value As Object)

End Sub

If you're not sure, you can type:

Sub then a space, then tab will list the available types, select one and press return and a list of available methods will be displayed, select one of those, then type the field name and press return.
 
Last edited:
Upvote 0

padvou

Active Member
Licensed User
Longtime User
Sure, but I want to fire an event as soon as the spinner is clicked. Not an item on the drop down list.
 

Attachments

  • test.zip
    6.8 KB · Views: 278
Upvote 0

padvou

Active Member
Licensed User
Longtime User
Sure, but I want to fire an event as soon as the spinner is clicked. Not an item on the drop down list.

Or maybe I could add a button to do that, but as soon as it's clicked it must expand the list of the spinner. Is that possible?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Here is an invisible panel that will call the spinners on click via reflection.

Edit: Erel beat me to it!
 

Attachments

  • spinnerclick.zip
    7.2 KB · Views: 404
Upvote 0
Top