2013-04-16 75 views
3

使用PhoneGap時按下菜單按鈕時,android本機菜單未打開。當我按menu按鈕時,onCreateOptionsMenu()方法正在調用,但菜單未創建。PhonePhone中未顯示原生android菜單

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; 
    } 

} 

日誌正在打印,這意味着函數被調用。

用於菜單的XML文件:當android:showAsAction設置爲always它顯示在操作欄中,否則它不工作。

<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> 

可能是什麼問題?

回答

3

解決了它。該錯誤在PhoneGap 2.6中。我下載了PhoneGap版本2.5,並正常工作。

+0

這將在PhoneGap 2.8中修復 - 請參閱https://groups.google.com/forum/?fromgroups=#!topic/phonegap/niJG55vtLCs。 – phenry