2013-10-26 42 views
1

我有一個包含菜單選項的應用程序,但在某些Jelly Bean設備中,我們沒有菜單軟鍵按鈕,所以在這種情況下我該如何顯示這些菜單選項? 我是否需要檢查sdk版本,基於哪個版本來實現功能? ,我無法在我的應用程序中使用hasPermanentMenuKey()函數。
我的應用程序的目標如何獲得Android API級別17設備的菜單選項?

android:minSdkVersion="9" 
android:targetSdkVersion="17" 

誰能給我什麼建議?

回答

1

我想,你一定給Android系統的9個特定的主題。 例 機器人:主題= 「@機器人:風格/ Theme.Light」

1) Since Android 4.0 we have Action Bar, so many of the device running Android 4.0 and above will not have Hardware Menu. 
2) All your Menu will be in action bar. 
3) So, you need to specify different theme to Android v-14 and above, for you app to display Action bar with your menu.otherwise you will not get Action bar so as you Menu. 

How To Do It 
1) In values/styles.xml 
    <resources> 
     <style name="AppBaseTheme" parent="android:Theme.Light"></style> 
      <style name="AppTheme" parent="AppBaseTheme"> </style> 
    </resources> 

2) In values-v14/styles.xml 
    <resources> 
     <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar"></style> 
    </resources> 

3) In AndroidManifest.xml 
     android:theme="@style/AppTheme" 
0

使用較低的minSDK版本。然後在那些設置中,也會有選項菜單的軟鍵。例如

android:minSdkVersion="5" 
0

由於動作條在蜂窩推出使用onCreateOptionsMenu您設置的菜單顯示在activity.If的動作條指定android:showAsAction="never|withText"項目進入溢出菜單...一些看起來像三個點一樣,並以全文顯示。

您可以使用您在預蜂窩使用相同的API:在Android清單

boolean onCreateOptionsMenu(Menu menu) 
    boolean onOptionsItemSelected(MenuItem item) 
相關問題