gpt4 book ai didi

android - getDrawable 错误

转载 作者:太空宇宙 更新时间:2023-11-03 13:36:50 27 4
gpt4 key购买 nike

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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com