Zsombor Erdődy-Nagy
Zsombor Erdődy-Nagy

Reputation: 16914

Is there any way to use Roboguice and ActionbarSherlock in one project?

I'd like to use the libraries mentioned in the title in one project.

However, both need my Activities to extend from a special Activity class: in the case of Roboguice it's RoboAcitivity, and it's FragmentActivity for ActionbarSherlock.

ActionbarSherlock extends the compatibility library, which is nice, because I also need to use fragments, and the project level s < API level 11.

Has anyone succeeded in doing this? Since Java does not support multiple inheritance (which is a good thing usually), I tried to make the FragmentActivity in the ActionbarSherlock project to extend RoboActivity instead of the standard Activity. But I can't get it to compile this way.

Part of the console output is:

[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'.

Upvotes: 13

Views: 5176

Answers (6)

schnatterer
schnatterer

Reputation: 7859

Starting with RoboGuice 3, the roboguice-sherlock framework is included in the RoboGuice distribution. The naming scheme for the class is still the same

All classes in this project have the same name as the RoboGuice ones, with 'Sherlock' inserted after the 'Robo', ie RoboSherlockListFragment

except that the classes now reside in the roboguice.activity package.
See RoboSherlockActivity for example.

Upvotes: 0

J&#246;rg
J&#246;rg

Reputation: 2461

Besides the issues with the compatibility library, you might also struggle with how to extend your activity both from RoboActivityand SherlockActivity - in Java, you don't have mulitple inheritance :-)

The way you solve this is by hand-crafting your own RoboSherlockActivity or use Roberto Tyley's library.

See example.

Upvotes: 6

AllDayAmazing
AllDayAmazing

Reputation: 2383

Another example of a working example and utility can be found here: http://search.maven.org/#artifactdetails%7Ccom.github.rtyley%7Croboguice-sherlock%7C1.3%7Cjar

Upvotes: 0

pl3kn0r
pl3kn0r

Reputation: 347

I would just like to add that by 'simply' adding roboguice-sherlock to your maven pom it magicly works.

    <dependency>
        <groupId>com.github.rtyley</groupId>
        <artifactId>roboguice-sherlock</artifactId>
        <version>1.5</version>
    </dependency>

Upvotes: 3

Manfred Moser
Manfred Moser

Reputation: 29912

Another example just got released on github. It uses a whole bunch of other good tools in additon. Check out https://github.com/github/gauges-android

Upvotes: 1

Max
Max

Reputation: 626

I'm sure there's a better way, but this is how I finally got ActionBarSherlock and RoboGuice working in my little app.

Upvotes: 8

Related Questions