Click here to Skip to main content
15,887,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to make a map activity and I want to add 2 buttons to the actionbar. I created the project with the Android Studio 0.8.4 and I'm not able to add the menu to the action bar.
pls help me

mapview.xml :

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/map"
    tools:context=".MapsActivity"
    android:name="com.google.android.gms.maps.SupportMapFragment"/>


Maps Activity.java

public class MapsActivity extends FragmentActivity implements LocationListener
   {@Override
       public boolean onCreateOptionsMenu(Menu menu) {
           MenuInflater menuInflater = getMenuInflater();
           menuInflater.inflate(R.menu.mapmenu, menu);

           // Calling super after populating the menu is necessary here to ensure that the
           // action bar helpers have a chance to handle this event.
           return true;
   }



mapmenu.xml

<?xml version="1.0" encoding="utf-8"?>

    <menu xmlns:tools="http://schemas.android.com/tools"
     xmlns:android="http://schemas.android.com/apk/res/android" >



    <item android:id="@+id/action_search"
        tools:ignore="AppCompatResource"
        android:orderInCategory="50"
        android:icon="@android:drawable/ic_menu_search"
        android:title="Caută"
        tools:showAsAction="ifRoom"/>
    <item android:id="@+id/action_cagain"
        android:icon="@drawable/ic_action_refresh"
        android:title="Încearcă din nou"
        android:orderInCategory="50"
        tools:ignore="AppCompatResource"
        tools:showAsAction="ifRoom"/>
</menu>



Manifest :

<activity
            android:configChanges="orientation|screenSize"
            android:name=".MapsActivity"
            android:uiOptions="splitActionBarWhenNarrow"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.ferenczandras.transportmures.HARTA" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>




thanks
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900