• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps not reaching onCreateOptionsMenu

omerhochman

Lurker
Sep 21, 2013
1
0
Hi,
I am trying to create an action bar.

I have an application with DrawerLayout
that has inside a ViewPager... and I implement a PagerAadapter and a class for the page fragment.

this is the activity_main.xml under layout folder

( I REMOVED xmlns LINK DOTS AND SLASH SO I CAN POST THIS)
[HIGH]<android.support.v4.widget.DrawerLayout
xmlns:android="httpschemasandroidcomapkresandroid"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
>

<!-- This is the main-->
<android.support.v4.view.ViewPager xmlns:android="httpschemasandroidcomapkresandroid"
xmlns:tools="schemasandroidcomtools"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<!--
This title strip will display the currently visible page title, as well as the page
titles for adjacent pages.
-->

<android.support.v4.view.PagerTitleStrip
android:id="@+id/pager_title_strip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#33b5e5"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:textColor="#fff" />

</android.support.v4.view.ViewPager>

<ListView
android:id="@+id/optionsMenu"
android:background="#000000"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
</android.support.v4.widget.DrawerLayout>[/HIGH]

And this is the main.xml found in menu folder
( I REMOVED xmlns LINK DOTS AND SLASH SO I CAN POST THIS)
[HIGH]<menu xmlns:android="httpschemasandroidcomapkresandroid">
<item android:id="@+id/action_settings"
android:title="@string/action_settings" />

<item android:id="@+id/action_details"
android:title="@string/action_details" />

<item android:id="@+id/action_details2"
android:title="@string/action_details2" />
</menu>
[/HIGH]

The problem is that It doesn't even reach onCreateOptionsMenu on the MainActivity... I tried everything:
- change android:minSdkVersion to 7, 11 and 14 (in the manifest uses-sdk tag)
- add attribute to menu items "showAsAction", and remove that attribute too
- make my page fragment override onCreateOptionsMenu

i debug it and it never reaches onCreateOptionsMenu, anywhere.
and the getActionBar() is of course null.

thanks!
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones