I am fairly new to Android development - coming from a WPF background.
I have created two Android projects in my "workspace" in Eclipse. One is called "TestProject", and the other called "TestLibraryProject".
Inside of "TestLibraryProject" I have created a custom view called BlueBox.
I now want to use BlueBox in my main layout of "TestProject". Knowing that I needed to reference "TestLibraryProject" from "TestProject" somehow, I right-clicked on "TestProject" and followed the menu:
Build Path -> Add Libraries
In the dialog that popped up I selected "Android Classpath Container", and in the immediate dialog following that I chose "TestLibraryProject" from the combo-box.
Two-fold question: 1. Is this the correct way to include "TestLibraryProject" into "TestProject" so that I can use it? 2. How can I now use BlueBox in my main layout XML?
I tried simply putting this in into the XML file:
<mypackage.TestLibraryProject.BlueBox
android:id="@+id/my_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
But that didn't work. I also tried referencing the namespace in my root layout element:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:binding="http://www.gueei.com/android-binding/"
xmlns:testlibrary="http://schemas.android.com/apk/res/android/mypackage2.TestLibraryProject"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
But that didn't seem to help.
Any suggestions? Ideas? Help?
Thanks!
To add a library project first make sure that your library project is actually marked as a library project
.
Right click on the project node --> properties --> Android --> Is Library checkbox --> OK
Then in your main Android project:
Right click the project node --> properties --> Android --> Add --> Select your library project --> OK --> OK
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With