I am trying to add an option menu in actionbar to my existing app but it is not working. If I create a new project with \"hello world\" default app I can see the button in a
For your information, I solved my problem of the actionBar by going on the layout XML file and then pressing on View Option -> Show Layout Decorations.
Hope it will solve your problem.
Cheers.
Spent 3 hours and eventually fixed it! Forget removing android:theme="@style/AppTheme" from your manifest. It makes run-time error. This is how I fixed the problem. Your activity should extend AppCompatActivity instead of Activity.
getSupportActionBar().show();
Simply paste this code in your java onCreate function.
Principale extends ActionBarActivity should take care of the issue
on create of your activity.
getSupportActionBar().setDisplayShowCustomEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(false);
customNav = LayoutInflater.from(this).inflate(
R.layout.action_bar_customvieew, null);
getSupportActionBar().setCustomView(customNav);
I had the same problem and I confirm that if you delete android:theme="@style/AppTheme"
from AndroidManifest.xml
, it will solve your problem.