FirstOne FirstOne - 2 months ago 6x
Android Question

Show spinner options only after fecthing data from web

How to show spinner options only after fetching it's to-be items from the web?

If the user touches the spinner, I want to first fetch the data from the web, parse it and set as the spinner items. The fetching / parsing works well, but the problem is that the spinner options show up too soon. I want it to only appear after the data's been fetched.

So, in short, I'd like a way to prevent the spinner from popping up until the list is fetched from the web.


After hours of tryharding, i finnaly did it.

Here's the result:

mySpinner.setOnTouchListener(new OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            boolean shouldHide = false;
            if (event.getAction() == MotionEvent.ACTION_UP) {
                shouldHide = someBooleanMethod();

            return shouldHide;


private boolean someBooleanMethod(){
        if(pseudoSpinnerItemCount == 1){
            return true;
            // let the user select an option
            return false;

In the android.developer


calls 'onTouch' and

True if the listener has consumed the event, false otherwise.

With this info, I just had to create some code that returns false if i want the items to be shown and true otherwise.

For some reason i feel that this should not be used like this, but it worked exactly as i wanted.