`
119568242
  • 浏览: 420285 次
  • 性别: Icon_minigender_1
  • 来自: 深圳/湛江
社区版块
存档分类
最新评论

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

 
阅读更多

 

动态改变按钮背景状态

 

很少用到 上次和六哥聊到。六哥有心 查了下  以下是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;
	}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics