android 改变button背景颜色,android button 代码设置背景色

import android.graphics.Color;

import android.graphics.drawable.Drawable;

import android.graphics.drawable.ColorDrawable;

private Drawable drawable_backup;

drawable_backup = pauseBtn.getBackground();

//获取背景,备份起来

pauseBtn.setBackgroundColor(Color.parseColor("#808080"));

//改变按钮的背景色

pauseBtn.setOnClickListener(this);

//

pauseBtn.setClickable(false);

//禁止点击

......

......

......

......

pauseBtn.setClickable(true);

//满足条件,使能点击

pauseBtn.setBackgroundDrawable(drawable_backup);

//还原背景色

你可能感兴趣的:(android,改变button背景颜色)