Как сделать hint для spinner
Отсюда http://stackoverflow.com/questions/6602339/android-spinner-hint
Отсюда http://stackoverflow.com/questions/6602339/android-spinner-hint
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), R.layout.sherlock_spinner_item) { @Override public View getView(int position, View convertView, ViewGroup parent) { View v = super.getView(position, convertView, parent); if (position == getCount()) { ((TextView)v.findViewById(android.R.id.text1)).setText(""); ((TextView)v.findViewById(android.R.id.text1)).setHint(getItem(getCount())); //"Hint to be displayed" } return v; } @Override public int getCount() { return super.getCount()-1; // you dont display last item. It is used as hint. } }; adapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); adapter.add("Item 1"); adapter.add("Item 2"); adapter.add("Hint to be displayed"); spinner.setSelection(adapter.getCount()); //display hint
spinner in android
ОтветитьУдалить