views:

245

answers:

3

I have a spinner, which mostly works. If a user selects one of the items in it, the 'onItemSelected' routine catches it just fine.

But if a user clicks the same spinner, but does not change from the already visible item that it's currently displaying, the 'onItemSelected' routine just ignores it, and the logs show:-

WARN/InputManagerService(577): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@437948b0

I there anyway to capture someone doing this? The idea is that my spinner contains a list of names, and when a user selects one from the spinner, it gets added to a listview.

I could just add another button to get the name from the spinner, but, screen-space is already lacking and I'd rather not add anymore content.

A: 

Never used the spinner but wouldn't it be possible to reset the spinners position in the onItemSelected routine? To some kind of null value that says "Please choose" or something.

softarn
The idea of having a 'park' heading in the spinner list has occurred to me, and it is quite easy to do using: -spinnersname.setSelection(0); // 0 = heading/park positionbut it seems like a bit of a bodge.
andy_spoo
A: 

Have you looked at setOnItemClickListener? If you implement your own AdapterView.OnItemClickListener and pass it in as the argument to mySpinner.setOnItemClickListener method you'll be able to get ahold of the position of the selected item inside the onItemClick method

Andrey
java.lang.RuntimeException: setOnItemClickListener cannot be used with a spinner.Which is what I thought would happen, but thanks anyway. It's only possible to use 'onItemSelected'.I think I'll go withh the 'park position' idea from softarn. But thanks for your suggestion.
andy_spoo
+1  A: 

It sounds like you don't actually want a Spinner, you're just using it for its popup dialog. You can create your own simple popup dialog like Spinner uses (as the result of an 'Add' button click in your UI perhaps?) by using AlertDialog.Builder. Spinner uses setSingleChoiceItems followed by show on an AlertDialog.Builder to present its choices to the user.

adamp