I want to capture the onClick event when the user selects a spinner value.
I've tried implementing OnClickListener
and using the following code:
@Override
public void onClick(final View view) {
if (view == countrySpinner) {
Toast.makeText(this, "Override OK!", 3);
}
}
And binding with:
countrySpinner.setOnClickListener(this);
This compiles, but I get a RuntimeException
advising me to use OnItemClickListener
rather than OnClickListener
for an AdapterView
.
How can I capture that onClick event?
Spinner
does not support click events, as the exception plainly tells you. Either use selection events or do not use aSpinner
. – TamanahaSpinner
has nothing to do with click events, any more than generating a Web page has anything to do with somebody clicking a link on the page itself once loaded in a browser. I have no idea what you think "eagerly" is. If you have questions on populating aSpinner
, please open a fresh SO question. – Tamanaha