问题描述
- 在标注的两处出现Duplicate case,怎么解决,稍微详细点,新手
-
public void onClick(View v){
switch(v.getId())
{
1. **** case R.id.button1:****
displayATM("1");
break;
case R.id.button2:
displayATM("2");
break;
case R.id.button3:
displayATM("3");
break;
case R.id.button4:
displayATM("4");
break;
case R.id.button5:
displayATM("5");
break;
case R.id.button6:
displayATM("6");
break;
case R.id.button7:
displayATM("7");
break;
case R.id.button8:
displayATM("8");
break;
case R.id.button9:
displayATM("9");
break;
case R.id.Back:
String str=edtATM.getText().toString();
if(str.length()>0){
str=str.substring(0,str.length()-1);
edtATM.setText(str);
}
break;
2.**** case R.id.OK:****
str=edtATM.getText().toString();
if(str.equals("123456789")){
Toast toast=Toast.makeText(MainActivity.this,"密码正确,欢迎使用提款功能!",Toast.LENGTH_LONG);
toast.show();
} else{
Toast toast=Toast.makeText(MainActivity.this,"密码错误,请重新输入!",Toast.LENGTH_LONG);
toast.show();
edtATM.setText("");
}
break;
}
时间: 2024-12-21 05:46:20