2011-10-15 68 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> 
相关问题