Step 1:
Your array looks like. last item your hint
Ex : private String[] yourArray = new String[] {"Staff", "Student","Your Hint"};
Step 2:
Create HintAdpater.java (Just copy & paste)
This class not return last item.. So your Hint not displays.
HintAdapter.java
package ajax.com.vvcoe.utils;
import android.content.Context;
import android.widget.ArrayAdapter;
import java.util.List;
public class HintAdapter extends ArrayAdapter<String> {
public HintAdapter(Context context, int resource) {
super(context, resource);
}
public HintAdapter(Context context, int resource, int textViewResourceId) {
super(context, resource, textViewResourceId);
}
public HintAdapter(Context context, int resource, String[] objects) {
super(context, resource, objects);
}
public HintAdapter(Context context, int resource, int textViewResourceId, String[] objects) {
super(context, resource, textViewResourceId, objects);
}
public HintAdapter(Context context, int resource, List<String> objects) {
super(context, resource, objects);
}
public HintAdapter(Context context, int resource, int textViewResourceId, List<String> objects) {
super(context, resource, textViewResourceId, objects);
}
@Override
public int getCount() {
// don't display last item. It is used as hint.
int count = super.getCount();
return count > 0 ? count - 1 : count;
}
}
Step 3:
Set spinner adapter like this
HintAdapter hintAdapter=new HintAdapter(this,android.R.layout.simple_list_item_1,yourArray);
yourSpinner.setAdapter(hintAdapter);
// show hint
yourSpinner.setSelection(hintAdapter.getCount());
Credit goes to @Yakiv Mospan from this answer - https://stackoverflow.com/a/22774285/3879847
I modify some changes only..