Thursday, May 15, 2014

action_search cannot be resolved or is not a field.
































First of all MyFirstApp runs fine with no errors. Now as That guy from thirdphaseofmoon says, let's get to it.
































I'm currently following this tutorial on adding the action bar to MyFirstApp. I followed the directions exactly. In fact, I copied and pasted the code into MyFirstApp but eclipse throws up this error, "action_search cannot be resolved or is not a field."
































Here's my code:
















































Java Code:





































public boolean onOptionsItemSelected(MenuItem item){
switch(item.getItemId()){
case R.id.action_search:
openSearch();
return true;
case R.id.action_settings:
openSettings();
return true;
default:
return super.onOptionsItemSelected(item);
}
}



































Additionally, there has been no response to a similar question on StackOverflow














































No comments:

Post a Comment