2012-03-22 82 views
1

我在羅技revue上運行我的應用程序。菜單沒有像應該顯示的那樣出現在頂部。你能指出我做錯了什麼,或者指引我使用一些資源。 以下是一些細節。爲什麼我的頂層菜單不會顯示?

  • 主題:Theme.holo
  • 機器人:的minSdkVersion = 「8」 機器人:targetSdkVersion = 「8」
  • 裝置:羅技歌劇團

下面是要領的一些片段:

public boolean onCreateOptionsMenu(Menu menu) { 
      super.onCreateOptionsMenu(menu); 
     Log.i("MENU","Opening menu"); 
     MenuInflater inflater = getMenuInflater(); 
     inflater.inflate(R.menu.menu, menu); 
     return true; 
    } 

在res /菜單我有menu.xml文件

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

<item android:id="@+id/catalog" 
    android:title="Profile info" 
    android:showAsAction="ifRoom" 
    android:icon="@drawable/ic_launcher"/> 


<item android:id="@+id/newvideos" 
    android:title="Playlist" 
    android:showAsAction="ifRoom" 
    android:icon="@drawable/ic_launcher" 
    /> 


<item android:id="@+id/popularvideos" 
    android:title="Play Video" 
    android:onClick="handleCick" 
    android:showAsAction="ifRoom" 
    android:icon="@drawable/ic_launcher" 
/> 

+0

我假設頂級菜單是指[ActionBar](http://developer.android.com/guide/topics/ui/actionbar.html)? – 2012-03-22 16:13:11

+0

@alextsc,是的我想要一個持久的酒吧沿着頂部用於導航。 – Fabii 2012-03-22 16:14:35

回答

2

表明你設置任何minSdkVersiontargetSdkVersion至11以上爲Action Bar - Adding the action bar描述的動作吧。我建議你改變targetSdkVersion以保持與較低的API級別兼容。

這是如何工作的一般,羅技revue似乎是一個谷歌電視設備。我對此沒有經驗,不確定是否有任何特殊的事情要考慮。

+0

當我將targetSdkVersion更改爲11時,程序崩潰。E/AndroidRuntime(20263):java.lang.RuntimeException:無法啓動活動ComponentInfo {com.ameba.api/com.ameba.api.Home}:android.os。 NetworkOnMainThreadException – Fabii 2012-03-22 16:39:30

+2

@Fabii你明白,因爲你在UI線程上進行網絡調用。這個異常由[StrictMode](http://developer.android.com/reference/android/os/StrictMode.html)*([有關此的博文)(http://android-developers.blogspot.de /2010/12/new-gingerbread-api-strictmode.html))*。儘管這是一個完全不同的問題。如果你不能從文檔中找出它,請發佈一個新問題。 – 2012-03-22 16:49:16

相關問題