private int ServiceLeft;
private int ServiceRight;
private int Services;
final TextView countTextViewPlusL = (TextView) findViewById(R.id.TextViewCountL);
final Button ServiceButtonLeft = (Button) findViewById(R.id.ButtonServiceLeft);
final TextView countTextViewPlusR = (TextView) findViewById(R.id.TextViewCountR);
final Button ServiceButtonRight = (Button) findViewById(R.id.ButtonServiceRight);
View.OnClickListener listner = new View.OnClickListener() {
public void onClick(View v) {
switch(v.getId()) {
case R.id.ButtonServiceRight:
ServiceRight++;
break;
case R.id.ButtonServiceLeft:
ServiceLeft++;
break;
}
if(Services % 2 == 0) {
getDrawable(R.drawable.test);
}
}
};
我在“getDrawable”上遇到错误
getDrawable(R.drawable.test);
它说:getDrawable(int) 方法对于 new View.OnClickListener(){} 类型是未定义的。
如何解决这个问题?
最佳答案
试试这个 :
MyActivity.this.getResources().getDrawable(R.id.test);
关于android - getDrawable 上的错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6074805/