dejavu
dejavu

Reputation: 3254

Native android menu not showing in Phonegap

The android native menu is not opening when pressing menu button while using PhoneGap. When I am pressing menu button, onCreateOptionsMenu() method is getting called but the menu is not getting created.

public class PhoneGapActivity extends DroidGap {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.setBooleanProperty("showTitle", true);
        super.onCreate(savedInstanceState);
        super.loadUrl("file:///android_asset/www/index.html");
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        super.onCreateOptionsMenu(menu);
        Log.d("Menu","Menu option called");
        getMenuInflater().inflate(R.menu.phone_gap, menu);
        return true;
    }

}

The log is getting printed, that means the function is getting called.

XML file for menu: When the android:showAsAction is set to always its showing in the action bar, otherwise its not working.

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

    <item
        android:id="@+id/action_settings"
        android:icon="@drawable/ic_menu_settings_holo_light"
        android:showAsAction="always"
        android:title="@string/action_settings"/>

    <item
        android:id="@+id/more"
        android:icon="@drawable/ic_menu_moreoverflow_normal_holo_light"
        android:showAsAction="never"
        android:title="@string/more"/>

</menu>

What could be the problem?

Upvotes: 3

Views: 1575

Answers (1)

dejavu
dejavu

Reputation: 3254

Solved it. The bug was in PhoneGap 2.6. I downloaded PhoneGap version 2.5 and it worked normally.

Upvotes: 3

Related Questions