I am trying to duplicate the three dots menu in the actionbar to my other pages/activities. In my app I use buttons to navigatie to he next screen. I copied the code:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
But nothing shows up in the next screen. I also tried adding items, standard it only has 'settings' but that doesn't work either. I imported the view.menu. The Actionbar itself with my appIcon does show. Making a new xml in the 'menu' folder as used in the code above, does not work.
manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ql"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="com.example.ql.permission.MAPS_RECEIVE"/>
<uses-permission android:name="com.example.ql.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-library android:name="com.google.android.maps" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCPlVHMostdkcJrs5YvkCXxHQaR94LrxEc"/>
<activity
android:name="com.example.ql.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.ql.ContactActivity" >
</activity>
<activity
android:name="com.example.ql.MediaActivity" >
</activity>
<activity
android:name="com.example.ql.CommunityActivity" >
</activity>
<activity
android:name="com.example.ql.PersoonlijkActivity" >
</activity>
<activity
android:name="com.example.ql.NieuwsActivity" >
</activity>
<activity
android:name="com.example.ql.PortalActivity" >
</activity>
<activity
android:name="com.example.ql.StreamActivity" >
</activity>
<activity
android:name="com.example.ql.GpsActivity" >
</activity>
</application>
</manifest>
Style.xml
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
Your style should use the holo style as base:
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
After making a tutorial for googlemaps in a different project I migrated the working code into my other project, which is discussed up here. I tried the application and it still didn't work well, still no menu and still no different theme. Then I went to my 'build target' and I saw that the google playserverice 'is library' box was checked, I unchecked it and tried my application, And now it did work, different style and it showed the menu-items I added in the default menu.xml.
Thank you all for your awnsers
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.