2013-04-16 74 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