Android 용 앱을 디자인하려고합니다.자바에서 변수 값이 변경됨
내가 원하는, 등을 button1, x
1로 설정하고, 1 단추 2 y
세트를 도청 할 때
는 그 다음에 문 경우 이러한 변수를 사용합니다.
int z;
int y;
int w;
final Button m = (Button) findViewById(R.id.button1);
final Button m1 = (Button) findViewById(R.id.button4);
final Button m2 = (Button) findViewById(R.id.button5);
m.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
// some code here
z == 1;
return false;
}
});
m1.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
// some code here
z == 1;
return false;
}
});
m2.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
// some code here
z == 1;
return false;
}
});
if (x == 1 & y == 1 & z == 1) {
finish();
//some code here
}
"if"내부 블록에 도달하지 않습니다. 어떻게 해결할 수 있습니까?
감사합니다.
코드를 올바르게 포맷하는 방법을 배워야합니다. 귀하의 문제와 관련하여 : Hexafraction이 옳습니다. 하나의 등호를 사용하여 변수에 값을 할당해야합니다. – Ahmad
당신은 'if (x == 1 && y == 1 && z == 1)'와 같이 논리적으로'&&'를 사용해야합니다. 하나의'&'는 모든 것이 홀수지만 당신이 생각하는 것을하지 않으면 작동 할 비트 연산자입니다. – Simon
== 잘못된 유형입니다. "if"가 작동하지 않습니다. (시도했지만 &&하지만 아직 작동하지 않았습니다.) – meysam