2011-10-15 67 views
13

我想在一個項目中使用標題中提到的庫。有沒有辦法在一個項目中使用Roboguice和ActionbarSherlock?

但是,兩者都需要我的活動來擴展一個特殊的Activity類:對於Roboguice而言,它是RoboAcitivity,它是用於ActionbarSherlock的FragmentActivity。

ActionbarSherlock擴展兼容性庫,這是很好的,因爲我還需要使用片段和項目級別s < API級別11

有沒有人成功地做到了這一點?由於Java不支持多重繼承(通常這是一件好事),我試圖在ActionbarSherlock項目中使FragmentActivity擴展RoboActivity而不是標準的Activity。但我無法通過這種方式進行編譯。控制檯輸出的

部分是:

[2011-10-15 17:46:31 - RetainFragmentTest2] /Users/scythe/JavaLibs/JakeWharton-ActionBarSherlock-a4855d0/library/res/values-v11/abs__styles.xml:170: error: Error: No resource found that matches the given name: attr 'android:logo'. 
[2011-10-15 17:46:31 - RetainFragmentTest2] /Users/scythe/JavaLibs/JakeWharton-ActionBarSherlock-a4855d0/library/res/values-v11/abs__styles.xml:171: error: Error: No resource found that matches the given name: attr 'android:navigationMode'. 
[2011-10-15 17:46:31 - RetainFragmentTest2] /Users/scythe/JavaLibs/JakeWharton-ActionBarSherlock-a4855d0/library/res/values-v11/abs__styles.xml:174: error: Error: No resource found that matches the given name: attr 'android:progressBarPadding'. 
[2011-10-15 17:46:31 - RetainFragmentTest2] /Users/scythe/JavaLibs/JakeWharton-ActionBarSherlock-a4855d0/library/res/values-v11/abs__styles.xml:176: error: Error: No resource found that matches the given name: attr 'android:subtitle'. 
[2011-10-15 17:46:31 - RetainFragmentTest2] /Users/scythe/JavaLibs/JakeWharton-ActionBarSherlock-a4855d0/library/res/values-v11/abs__styles.xml:177: error: Error: No resource found that matches the given name: attr 'android:subtitleTextStyle'. 
[2011-10-15 17:46:31 - RetainFragmentTest2] /Users/scythe/JavaLibs/JakeWharton-ActionBarSherlock-a4855d0/library/res/values-v11/abs__styles.xml:173: error: Error: No resource found that matches the given name: attr 'android:titleTextStyle'. 
+0

你太貪婪我認爲:P 但我覺得你的問題是因爲abs_styles沒有提及的屬性 – the100rabh

回答

6

除了與兼容性庫的問題,你也可能會如何既從RoboActivitySherlockActivity拓展業務,奮鬥 - 在Java中,你不必多張繼承:-)

方式你解決這個問題是通過手工製作你自己的RoboSherlockActivity或使用 Roberto Tyley's library

參見example

3

我只想補充一點,只需將roboguice-sherlock添加到您的maven pom中即可。

<dependency> 
     <groupId>com.github.rtyley</groupId> 
     <artifactId>roboguice-sherlock</artifactId> 
     <version>1.5</version> 
    </dependency> 
相關問題