Android menu not recognizing onClick in xml file



Here is my xml file (res/menu/main.xml):



<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_settings"
android:onClick="onClickMenu"
app:showAsAction="never"/>


and the following is in my main activity class:



@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}


public void onClickMenu(MenuItem item){
disp.setText("TextVisibleAfterClick");

}


Why is it that my code keeps throwing the following error?!:



android.view.InflateException: Couldn't resolve menu item onClick handler onClickMenu in class android.view.ContextThemeWrapper


I'm not understanding because I am accepting a MenuItem in my method and the XML paramater for onClick is the exact same!


No comments:

Post a Comment