tags:

views:

54

answers:

2

I'm attempting to use a custom Android vertical scrollbar widget that seems to work fine in its own example project, but I am having trouble trying to include it into my project. I've exported a .jar from it to use in my project, but it seems to be a minefield of problems, from duplicate resources, to my XML layouts not able to get at styles inside the library, and errors "inflating class" when reading my XML layout file.

How should I go about using the widget from another project in my own?

Quite new to Java development (know the language, but not much of the overarching project/package management), so if there's some good text regarding that it would be appreciated.

+1  A: 

Create an Android Library Project for the widget.

fhucho
How do I expose a particular widget (`View` subclass)? I actually can't even seem to get the example activity exposed (Eclipse only lets me `import [...].R;` without complaining that it cannot be resolved
Nick T
Seems like it magically fixed itself with an Eclipse restart `:/`
Nick T
A: 

As far as I can understand the problem should be related to the "R" class which is created in the same package as the main activity. When you create the new project this class is located in "the wrong place".

Giving up compatibility and require the use of the same package in all projects is not an option: market will not allow you to publish more than one application per namespace. Moreover, is is not a good practice for software engineering.

A much better solution is, as already pointed out by fhucho, to create a library project with your widget to be imported in the main application project.

If you are also looking for a book on android development and already know java I usually recommend "Hello Android" by Ed Burnette, it is quick to read but gives a nice overview with examples.

Dario