I’m using ActionBarSherlock and then onOptionsItemSelected to start a new activity when a specific menu item has been clicked. The code worked properly before adding ABS, and now I get case expressions must be constant expressions error on case.
@Override
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item)
{
switch (item.getItemId()) {
case R.id.about: //error
startActivity(new Intent(this, AboutActivity.class));
break;
case R.id.feedback: //error
//launch activity
break;
default:
break;
return super.onOptionsItemSelected(item);
}
The same code worked fine before adding ActionBarSherlock.
I’ve replaced the
switch/casestatement withif/else. You can just click onswitchand then pressCTRL+1if you’re in Eclipse.