get StateListDrawable - Android Graphics

Android examples for Graphics:State List Drawable

Description

get StateListDrawable

Demo Code


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

import android.graphics.drawable.StateListDrawable;

public class Main {
    /**/*from   w w w  . j ava 2s  . c  om*/
     * 
     * @param pressed
     * @param normal
     * @return
     */
    public static StateListDrawable getSelector(Drawable pressed,
            Drawable normal) {
        StateListDrawable stateDrawable = new StateListDrawable();
        stateDrawable.addState(new int[] { android.R.attr.state_pressed },
                pressed);
        stateDrawable.addState(new int[] {}, normal);
        return stateDrawable;
    }
}

Related Tutorials