get Selector StateListDrawable - Android Graphics

Android examples for Graphics:Drawable

Description

get Selector StateListDrawable

Demo Code


//package com.java2s;

import android.graphics.drawable.Drawable;

import android.graphics.drawable.StateListDrawable;

public class Main {

    public static StateListDrawable getSelector(Drawable normalDraw,
            Drawable pressedDraw) {/*from   w  ww .  ja va  2s . c  om*/
        StateListDrawable stateListDrawable = new StateListDrawable();
        stateListDrawable.addState(
                new int[] { android.R.attr.state_enabled }, pressedDraw);
        stateListDrawable.addState(new int[] {}, normalDraw);
        return stateListDrawable;
    }
}

Related Tutorials