1.设置背景图片,图片来源于drawable;
button.setBackgroundDrawable(getResources().getDrawable(R.drawable.search_label_click));
2.转换字符串为int(颜色);
button.setBackgroundColor(Color.parseColor("#F5F5DC"));
3.引用资源
button.setBackgroundResource(R.drawable.shapegray);
4.设置图片背景色
button.setBackgroundColor(Color.parseColor("#C8C8C8"));