ITeye博客

[android]动态改变按钮背景状态 StateListDrawable

119568242 · 2012-10-29 10:52 · Android · 移动开发 · Markdown

动态改变按钮背景状态

 

很少用到 上次和六哥聊到。六哥有心 查了下  以下是DEMO

 

 

public static StateListDrawable setStateListDrawable(Context mActivity,
			int up, int down) {
		StateListDrawable stateListDrawable = new StateListDrawable();
		BitmapDrawable db = new BitmapDrawable(mActivity.getResources(),
				LoadImage.loadImage(mActivity.getResources(), down));
		stateListDrawable.addState(new int[] { android.R.attr.state_pressed },
				db);
		db = new BitmapDrawable(mActivity.getResources(), LoadImage.loadImage(
				mActivity.getResources(), up));
		stateListDrawable.addState(new int[] {}, db);
		return stateListDrawable;
	}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。