Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: LGPL 

import android.graphics.Bitmap;

import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.StateListDrawable;

public class Main {
    public static StateListDrawable bgColorDrawableSelector(Bitmap nomal, Bitmap focus) {

        @SuppressWarnings("deprecation")
        BitmapDrawable nomalBitmap = new BitmapDrawable(nomal);
        @SuppressWarnings("deprecation")
        BitmapDrawable focusBitmap = new BitmapDrawable(focus);
        StateListDrawable selector = new StateListDrawable();
        selector.addState(new int[] { android.R.attr.state_pressed }, focusBitmap);
        selector.addState(new int[] { android.R.attr.state_selected }, focusBitmap);
        selector.addState(new int[] { android.R.attr.state_focused }, focusBitmap);
        selector.addState(new int[] {}, nomalBitmap);
        return selector;
    }
}