android的selector选择器

1. drawable/actionbar_compat_item.xml

 

2.drawable/actionbar_compat_item_pressed.xml

 

3.drawable/actionbar_compat_item_focused.xml

4.

public StateListDrawable setbg(Integer[] mImageIds) {

        StateListDrawable bg = new StateListDrawable();

        Drawable normal = this.getResources().getDrawable(mImageIds[0]);

        Drawable pressed = this.getResources().getDrawable(mImageIds[1]);

        Drawable focused = this.getResources().getDrawable(mImageIds[2]);
bg.addState(View.EMPTY_STATE_SET, normal);
bg.addState(view.PRESSED_ENABLED_STATE_SET,pressed);
   bg.addState(View.FOCUSED_STATE_SET, focused);

return bg; }
原文地址:https://www.cnblogs.com/yuyutianxia/p/3491217.html