This is my code:
public class className extends Activity{
private MenuActivity menuActivity;
@Override
public void onCreate(Bundle savedInstanceState) {
try {
ViewConfiguration config = ViewConfiguration.get(this);
Field menuKeyField = ViewConfiguration.class
.getDeclaredField("sHasPermanentMenuKey");
if (menuKeyField != null) {
menuKeyField.setAccessible(true);
menuKeyField.setBoolean(config, false);
}
} catch (Exception e) {
e.printStackTrace();
}
menuActivity = new MenuActivity(this, context, R.menu.menu);
);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menuActivity.onCreateOptionsMenu(menu); // <--
return super.onCreateOptionsMenu(menu);
}
}
public class MenuActivity {
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = mRootActivity.getMenuInflater();
inflater.inflate(typeMenu, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {
}
// ...
}
I receive a NullPointerException
on row:
menuActivity.onCreateOptionsMenu(menu);
This exception is present only some moble like Galaxy note. Do you know why there is this exception?
.
stackoverflow.comm
No comments:
Post a Comment