我有1 button
和text view
。
我想在每次点击0-5
时显示text view
中的号码button
。
int index = 2;
switch (index) {
case 0:
// if we are using index 0, set the text to index 1 text and change index to 1
index = 1;
line2.setText(0);
break;
case 1:
index = 2;
line2.setText(1);
break;
case 2:
index = 0;
line2.setText(2);
break;
}
我曾尝试过互联网上提供的大多数示例,但它没有改变价值。 任何人都可以帮我解决这个问题。
先谢谢。
答案 0 :(得分:2)
int mCounter = 0;
按钮的 onClick():
if(mCounter>4){
mCounter=0;
}
mCounter++;
txtInfo.setText(""+mCounter);
希望它会对你有所帮助。