Create a selector StateListDrawable drawable - Android Graphics

Android examples for Graphics:State List Drawable

Description

Create a selector StateListDrawable drawable

Demo Code


//package com.java2s;
import android.graphics.drawable.Drawable;

import android.graphics.drawable.StateListDrawable;

public class Main {

    public static StateListDrawable createSelector(Drawable pressed,
            Drawable normal) {/*from  w ww. j  av  a  2 s . co m*/
        StateListDrawable drawable = new StateListDrawable();
        drawable.addState(new int[] { android.R.attr.state_pressed },
                pressed);
        drawable.addState(new int[] {}, normal);
        return drawable;
    }
}

Related Tutorials