2013-10-17 137 views
0

我想包括動作條V7在我的應用程序。在AndroidManifest.xml我把ActionBar V7:爲什麼它不起作用?

android:icon="@drawable/ic_launcher" 
android:label="@string/app_name" 
android:theme="@style/AppTheme" > 

在值/ style.xml

<resources> 

     <!-- 
      Base application theme, dependent on API level. This theme is replaced 
      by AppBaseTheme from res/values-vXX/styles.xml on newer devices. 
     --> 
     <style name="AppBaseTheme" parent="Theme.AppCompat.Light"> 
      <!-- 
       Theme customizations available in newer API levels can go in 
       res/values-vXX/styles.xml, while customizations related to 
       backward-compatibility can go here. 
      --> 

    </style> 
     <!-- Application theme. --> 
     <style name="AppTheme" parent="AppBaseTheme"> 

      <!-- All customizations that are NOT specific to a particular API-level can go here. --> 
     </style> 

</resources> 

在值-V11

<?xml version="1.0"?> 
-<resources> 
<!-- Base application theme for API 11+. This theme completely replaces AppBaseTheme from res/values/styles.xml on API 11+ devices. --> 
-<style parent="Theme.AppCompat.Light" name="AppBaseTheme"> 
<!-- API 11 theme customizations can go here. --> 
</style></resources> 

和價值-V14

<resources> 

    <!-- 
     Base application theme for API 14+. This theme completely replaces 
     AppBaseTheme from BOTH res/values/styles.xml and 
     res/values-v11/styles.xml on API 14+ devices. 
    --> 
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light"> 
     <!-- API 14 theme customizations can go here. --> 
    </style> 

</resources> 

在活動我把

import android.support.v7.app.ActionBarActivity; 
public class MainActivity extends ActionBarActivity 

在執行時告訴我,有項目的錯誤。正是這些錯誤在所有style.xml和錯誤是「錯誤:項目出錯檢索父:沒有資源發現在給定名稱匹配‘Theme.AppCompat.Light’ 。」爲什麼我有這樣的錯誤,以及如何解決呢?我把庫android-support-v7-appcompat.jar放在/ libs中,然後右鍵點擊它將它添加到Build Patch中。我也嘗試重新啓動eclipse,但它的工作方式不一樣。

+0

你看了,你需要怎麼設置庫http://developer.android.com/ tools/support-library/setup.html? – Luksprog

+0

使用'@ Theme.AppCompat.Light'不'Theme.AppCompat.Light'。你忘了在主題名稱前添加「@」。 – hardartcore

回答

相關問題