我最近在
android
java应用程序中添加了另一个菜单项,并且惊讶于
Eclipse表示从前一种情况的变量:break不是本地的(所以我刚刚添加了一个后缀来获得).
在我心中有点困惑,第一组情况:如果选择第二个选项,休息不会被执行.有人可以解释我错误的想法吗?
case R.id.menuDebugMode: debugMode = !debugMode; if (debugMode){ Toast.makeText(mainActivity.this,"Debug Mode on - NOT TO BE USED WHILST DRIVING",Toast.LENGTH_LONG).show(); } else { tvDebug.setText(""); tvInfo.setText(""); } SharedPreferences settings = getSharedPreferences(PREFS_NAME,0); SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("debugMode",debugMode); editor.commit(); break; case R.id.menuSpeedMode: speedSignMode = !speedSignMode; if (speedSignMode){ Toast.makeText(mainActivity.this,"SpeedSign Mode in use",Toast.LENGTH_LONG).show(); } else { Toast.makeText(mainActivity.this,"MapSpeed Mode in use",Toast.LENGTH_LONG).show(); } SharedPreferences settings2 = getSharedPreferences(PREFS_NAME,0); SharedPreferences.Editor editor2 = settings2.edit(); editor2.putBoolean("speedSignMode",speedSignMode); editor2.commit(); break;`