我對Android開發頗爲新穎 - 來自WPF背景。Android:使用我工作區中另一個項目的資源
我在Eclipse的「工作區」中創建了兩個Android項目。一個叫做「TestProject」,另一個叫做「TestLibraryProject」。
「TestLibraryProject」內部我創建了一個名爲BlueBox的自定義視圖。
我現在想在我的主要佈局「TestProject」中使用BlueBox。知道我需要引用「TestLibraryProject」,從「TestProject」不知怎麼的,我的「TestProject」右鍵單擊並遵循菜單:
構建路徑 - >添加庫
在對話框彈出我選擇「Android類路徑容器」,並在隨後的立即對話框中從組合框中選擇「TestLibraryProject」。
雙重問題: 1.這是將「TestLibraryProject」包含到「TestProject」中以便我可以使用它的正確方法嗎? 2.我現在如何在我的主佈局XML中使用BlueBox?
我試圖簡單地把這個在成XML文件:
<mypackage.TestLibraryProject.BlueBox
android:id="@+id/my_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
但沒有奏效。我也嘗試在我的根佈局元素中引用命名空間:
<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" >
但這似乎沒有幫助。
有什麼建議嗎?想法?幫幫我?
謝謝!
希望這會幫助你http://android-developers.blogspot.com/2011/10/changes-to-library-projects-in-android.html – Olsavage