I try to used setHasOptionsMenu(true);
in my activity but i get an error. "cannot resolve method setHasOptionsMenu".
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.job_status_option_menu, menu);
return super.onCreateOptionsMenu(menu);
}
Try to remove setHasOptionMenu(true)
from your onCreate()
method, and change the onCreateOptionsMenu
in this way:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.job_status_option_menu, menu);
return true;
}
You should place this method call inside the oncreateview of fragment if you use fragments inside activity. Or else you don't have to use this invocation inside activity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With