设置setBackgroundResource失败,仅在应用程序在android中运行后成功 public void ClearButtonColor(){ 对于(int i=0;i
首先清除后台资源,然后可以添加新资源:设置setBackgroundResource失败,仅在应用程序在android中运行后成功 public void ClearButtonColor(){ 对于(int i=0;i,android,Android,首先清除后台资源,然后可以添加新资源: public void ClearButtonColor(){ for(int i=0; i<=myButtons.length-1; i++){ myButtons[i].setBackgroundResource(android.R.drawable.btn_default); } } public void ClearButtonColor(){ 对于(int i=0;i不再工作。会发生什么情
public void ClearButtonColor(){
for(int i=0; i<=myButtons.length-1; i++){
myButtons[i].setBackgroundResource(android.R.drawable.btn_default);
}
}
public void ClearButtonColor(){
对于(int i=0;i不再工作
。会发生什么情况?@Simon按钮不会更改回默认颜色。当只运行一次应用程序时,可以更改回按钮颜色,第二次调用ClearbuttonColor将不再更改回原来的颜色。当用户按下按钮时,我的应用程序将更改按钮的背景颜色,但当按下clear按钮时,ey能够清除所有按钮的背景色,并将调用clearButtonColor函数。哈哈!这是工作!为什么必须首先清除资源?我不理解逻辑,因为它不能自动清除以前的资源,我们总是需要通过给它零作为参数来判断。@ChinYe
public void ClearButtonColor(){
for(int i=0; i<=myButtons.length-1; i++){
myButtons[i].setBackgroundResource(0);
myButtons[i].setBackgroundResource(android.R.drawable.btn_default);
}
}