Search code examples
androidandroid-spinnerandroid-event

Hidden Spinner does not trigger event


I have a spinner in an Activity, the spinner is hidden initially, but when I load the items into it I initially set the selected item to the index 1, like this:

spinner.setSelection(1);

This triggers the item selected listener only if the spinner is not hidden, but if I hide it (I need to hide it initially to show a progressbar while I load some data) then the listener is not called.

Is there a way I can force the event to dispatch?


Solution

  • Change visibility from View.GONE to View.INVISIBLE- invisible takes Screen space,which means android takes it into account but its just not visible to the user or set alpha on your View or ViewGroup