I am trying to create a Spinner where the first item in dropdownview does not have a switch. I am redefining the types of arrayadapter types to make sure that there are two different types in the spinner and that the views are not returned for the wrong element. Then I override getDropDownView from the array to remove the switch from the first element. This works, but the selected item does not show a switch. I think I did not need to install CheckMarkDrawable (android.R.drawable.btn_radio), because it should always be there, but it is not. Any ideas? Thanks!
@Override public int getViewTypeCount() { return 2; } @Override public int getItemViewType(int position) { if (position == 0) return 0; else return 1; } @Override public View getDropDownView(int position, View convertView, android.view.ViewGroup parent) { if (position == 0) { View vw = super.getDropDownView(position, convertView, parent); CheckedTextView tv = (CheckedTextView) vw; if (tv != null) { tv.setCheckMarkDrawable(null); tv.setTextColor(Color.GRAY); return tv; } return vw; } else { View vw = super.getDropDownView(position, convertView, parent); CheckedTextView tv = (CheckedTextView) vw; if (tv != null) { tv.setCheckMarkDrawable(android.R.drawable.btn_radio); tv.setTextColor(Color.BLACK); return tv; } return vw; } }
source share