我想#000000
为选中和#FFFFFF
未选中状态创建一个可绘制的选择器。
如何以编程方式创建可绘制对象?
目前我正在这样做:
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);