Code example for StateListDrawable

Methods: addState

0
        if(focused == null) {
            focused = pressed;
        } 
        StateListDrawable std = null;
        if(pressed != null && focused != null && normal != null) {
            std = new StateListDrawable();
            std.addState(new int[] {android.R.attr.state_pressed}, pressed);
            std.addState(new int[] {android.R.attr.state_focused}, focused);
            std.addState(new int[] {}, normal);
        } 
         
        if(std != null) {
            UtilityWrapper.getInstance().setBackgroundDrawable(v, std);
        } 
    } 
     
 
    public void applyBackgroundStateListSelectableDrawable(View v, String prefix) {
        Drawable pressed = getDrawableResource(prefix+"_press");
        Drawable focused = getDrawableResource(prefix+"_focus");
        Drawable selected = getDrawableResource(prefix+"_selected");