2012-12-14 31 views
2

嘗試使用this庫編譯項目。 IntelliJ IDEA 12在themes.xml中的非標準元素上顯示錯誤,並且不編譯。IntelliJ IDEA 12和themes.xml中的非標準項目

項目:

<style name="SampleTheme" parent="android:Theme.Holo"> 
    <item name="numberPickerUpButtonStyle">@style/NPWidget.Holo.ImageButton.NumberPickerUpButton</item> 
    <item name="numberPickerDownButtonStyle">@style/NPWidget.Holo.ImageButton.NumberPickerDownButton</item> 
    <item name="numberPickerInputTextStyle">@style/NPWidget.Holo.EditText.NumberPickerInputText</item> 
    <item name="numberPickerStyle">@style/NPWidget.Holo.NumberPicker</item> 
</style> 

錯誤:

android-apt-compiler: [samples] /Users/max/work/libs/android-numberpicker/samples/res/values/themes.xml:5: error: Error: No resource found that matches the given name: attr 'numberPickerDownButtonStyle'. 
android-apt-compiler: [samples] /Users/max/work/libs/android-numberpicker/samples/res/values/themes.xml:6: error: Error: No resource found that matches the given name: attr 'numberPickerInputTextStyle'. 
android-apt-compiler: [samples] /Users/max/work/libs/android-numberpicker/samples/res/values/themes.xml:7: error: Error: No resource found that matches the given name: attr 'numberPickerStyle'. 
android-apt-compiler: [samples] /Users/max/work/libs/android-numberpicker/samples/res/values/themes.xml:4: error: Error: No resource found that matches the given name: attr 'numberPickerUpButtonStyle'. 

如果你使用和其他圖書館也會出現此問題。

如何解決這個問題?

回答

2

請檢查您是否正在使用最近的Android平臺進行該項目。在Module Dependencies應該有4.0.x的或更高平臺版本:

Android Platform

+0

,我仍然面臨着這個問題。 –

+0

@IgorGanapolsky:請分享一個在命令行中構建的示例項目,但在IDEA中失敗。 – CrazyCoder

+0

該問題的主要原因是attrs.xml需要具有上述樣式引用。此外,包含這些樣式引用的項目需要在Idea中設置爲庫項目。一旦完成,該項目建好。這不是SDK版本造成的。 –

1

您需要在同一個樣式來定義這些屬性類型文件,如resources節點的子:

<attr name="numberPickerUpButtonStyle" format="reference" /> 
+0

「資源節點的孩子」是什麼意思?我把它放在之下,而我的其他標籤開始引發編譯錯誤。 –

+0

@Igor,以XML樹形式表示。你關閉了「資源」標籤嗎?你能用你的代碼創建一個主題嗎? –

+0

基本上這些值需要在attrs.xml中。這是我混亂的根源。 –

0

您的圖書館項目可能編譯爲應用程序項目。要更改此項,請轉至:

文件>項目結構>構面> [庫名稱]>選中「庫模塊」。

1
  • 你應該到Android-numberpicker模塊的Android calendarview庫太(由SimonVT再次)添加爲一個依賴
  • 添加這些庫作爲依賴於你的主模塊。
  • 將這些添加的項目標記爲圖庫項目
  • 將此樣式添加到您的styles.xml中,您在項目中使用了什麼。 (你可以改變風格過於當然)

    <item name="numberPickerStyle">@style/NPWidget.Holo.NumberPicker</item> 
    
+0

這導致我解決了我的問題,出於某種原因,我不得不刪除並再次導入SimonVT numberPicker庫並刪除並重新添加庫。現在numberPickerStyle得到了重新確認。 – GMBrian

0

NumberPicker/DataPicker模塊應該我使用的Android 4.2谷歌的API被設置爲SDK4.2