Search code examples
javaandroidspinnerhint

Putting a hint on an android spinner


I'm making a tiny application, and I have a spinner. Right now it shows the first option of the spinner as the text on the spinner when the application loads. I'd like it to show some special text like a hint when it loads the application. But when you press the spinner and get up the options, I would love for it to show the original options. Like right now it shows option number 0 when you load the application, but I want the text on it to say some other string.

Is this possible?


Solution

  • Suppose now 0 is Selected But when App loading it set other String Which selection is in onItemSelected method

     spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
    
                        @Override
                        public void onItemSelected(AdapterView<?> arg0, View arg1,
                                int arg2, long arg3) {
                            spinner.setSelection(2);
    
                        }
    
                        @Override
                        public void onNothingSelected(AdapterView<?> arg0) {
                            // TODO Auto-generated method stub
    
                        }
                    });