I want to create a selector drawable with #000000
for selected and #FFFFFF
for unselected state.
How can I create a drawable programmatically?
Currently I am doing it as following:
StateListDrawable states = new StateListDrawable();
ColorDrawable cdPress = new ColorDrawable(0xFF0000);
ColorDrawable cdUnPress = new ColorDrawable(0x0101DF);
states.addState(new int[] { android.R.attr.state_selected}, cdPress);
states.addState(new int[] {-android.R.attr.state_selected}, cdUnPress);
view.setBackgroundDrawable(states);
view.setSelected(isSelected);
create stateListDrawable and pass to the view