Android-数组或for语句问题
我在一个应用程序上运行,但我对for或数组有问题。 当我使用这个代码时Android-数组或for语句问题,android,Android,我在一个应用程序上运行,但我对for或数组有问题。 当我使用这个代码时 Button Button[] = {(Button)findViewById(R.id.button01), (Button)findViewById(R.id.button02), (Button)findViewById(R.id.button03),(Button)findViewById(R.id.button04)}; 但是for语句跳过数组中的第一个按钮,第二个按钮获取id 1。有人知道我怎么修吗? 谢谢按
Button Button[] = {(Button)findViewById(R.id.button01), (Button)findViewById(R.id.button02), (Button)findViewById(R.id.button03),(Button)findViewById(R.id.button04)};
但是for语句跳过数组中的第一个按钮,第二个按钮获取id 1。有人知道我怎么修吗?
谢谢按钮是什么?它是变量还是类?很难看到这里到底发生了什么。哦,对不起,这是一个带按钮的数组。请使用另一个变量,因为名称是保留类的名称。你不能做整数=4;我尝试了SoundButton,但也不起作用:
case MotionEvent.ACTION_MOVE:
for (int i = 0; i < Button.length; i++) {
if (Y > Button[i].getTop()+25 && Y < Button[i].getBottom()+25 && X > Button[i].getLeft() && X < Button[i].getRight()){
LastButton = i;
edittext.setText("id " + i);
}
}
break;