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);
它说:对于 new View.OnClickListener(){} 类型,方法 getDrawable(int) 未定义。
如何解决?
最佳答案
试试这个:
MyActivity.this.getResources().getDrawable(R.id.test);
关于android - getDrawable 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6074805/