【发布时间】:2017-05-01 00:42:09
【问题描述】:
我花了 3 个小时尝试制作一个在用户单击时更改其图像的 ImageButton,但这对我来说是不可能的。提前致谢!
主要类
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageButton dado_btn = (ImageButton) findViewById (R.id.dado_button);
replace = R.drawable.face_1;
dado_btn.setBackgroundResource(replace);
}
public void OnClickTirada (View v){
//this doesn't work at all
dado_btn.setImageDrawable(getResources().getDrawable(R.drawable.face_1));
}
【问题讨论】:
标签: java android onclick imagebutton