I have problems with this type of code
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_sign_out_all:
doHardShutdown();
return true;
case R.id.menu_add_account:
// showExistingAccountListDialog();
return true;
case R.id.menu_settings:
Intent sintent = new Intent(this, SettingActivity.class);
startActivityForResult(sintent,0);
return true;
case R.id.menu_import_keys:
importKeyStore();
return true;
// case R.id.menu_exit:
// signOutAndKillProcess();
// return true;
}
return super.onOptionsItemSelected(item);
}
It happens in all code where is some switch/case. On every:
case R.id.XXX
eclipse returns me an error:"case expressions must be constants expressions"
Then I tried to delete R.java, clean, and regenerate it, but didn't work. How can I fix it?
Thats part of the xml:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_add_account"
android:title="@string/menu_add_account"
android:icon="@android:drawable/ic_menu_add"
app:showAsAction="always|withText"
>
</item>