Hi Jay, Your solution doesn't worked for me. Yes, the project could pass the compile without errors, but the attributes are never read at runtime.
Hank On Friday, March 2, 2012 4:22:40 AM UTC+8, Jay Kline wrote: > > Im using a slightly better kludge. Instead of having to include the xml > files, I declare the namespace as a string resource. So in your layout > just do xmlns:my="@string/package_ns" then just have the project that > uses it define the namespace. Seems to work ok. > > On Tuesday, February 8, 2011 8:01:27 AM UTC-6, Adam Tybor wrote: >> >> Its not great but what I have been doing is using includes and redefining >> the include in the application project. You can still define the attribute >> in the library project, you can use simple framelayouts or whatever to >> define a fake placeholder layout in the library project, then in the >> application project define the real view. When compiling the real view in >> the application project it will override the library project. This allows >> the code to compile with the R.syles stuff in the lirbary, yet still have >> the views work too. >> >> Best of luck, its kludgy but workable. >> Adam >> >> << Library >> >> res/values/attrs.xml: >> <resources> >> <declare-styleable name="MyWidget"> >> <attr name="customValue" format="integer"/> >> </declare-styleable> >> </resources> >> >> res/layout/myWidget.xml >> <TextView >> android:id="@+id/my_widget" >> android:layout_width="fill_parent" >> android:layout_height="fill_parent" >> android:text="Replace Me"/> >> >> res/layout/main.xml: >> <?xml version="1.0" encoding="utf-8"?> >> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ >> android" >> android:orientation="vertical" >> android:layout_width="fill_parent" >> android:layout_height="fill_parent" >> > >> <include layout="@layout/myWidget.xml" android:id="@+id/my_widget" /> >> </LinearLayout> >> >> >> << App Project>> >> res/layout/myWidget.xml >> <com.mycompany.test.lib.MyWidget xmlns:android=" >> http://schemas.android.com/apk/res/android" >> xmlns:my="http://schemas.android.com/apk/res/ >> android:id="@+id/my_widget" >> android:layout_width="fill_parent" >> android:layout_height="fill_parent" >> my:customValue="324"/> >> >> >> > On Tuesday, February 8, 2011 8:01:27 AM UTC-6, Adam Tybor wrote: >> >> Its not great but what I have been doing is using includes and redefining >> the include in the application project. You can still define the attribute >> in the library project, you can use simple framelayouts or whatever to >> define a fake placeholder layout in the library project, then in the >> application project define the real view. When compiling the real view in >> the application project it will override the library project. This allows >> the code to compile with the R.syles stuff in the lirbary, yet still have >> the views work too. >> >> Best of luck, its kludgy but workable. >> Adam >> >> << Library >> >> res/values/attrs.xml: >> <resources> >> <declare-styleable name="MyWidget"> >> <attr name="customValue" format="integer"/> >> </declare-styleable> >> </resources> >> >> res/layout/myWidget.xml >> <TextView >> android:id="@+id/my_widget" >> android:layout_width="fill_parent" >> android:layout_height="fill_parent" >> android:text="Replace Me"/> >> >> res/layout/main.xml: >> <?xml version="1.0" encoding="utf-8"?> >> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ >> android" >> android:orientation="vertical" >> android:layout_width="fill_parent" >> android:layout_height="fill_parent" >> > >> <include layout="@layout/myWidget.xml" android:id="@+id/my_widget" /> >> </LinearLayout> >> >> >> << App Project>> >> res/layout/myWidget.xml >> <com.mycompany.test.lib.MyWidget xmlns:android=" >> http://schemas.android.com/apk/res/android" >> xmlns:my="http://schemas.android.com/apk/res/ >> android:id="@+id/my_widget" >> android:layout_width="fill_parent" >> android:layout_height="fill_parent" >> my:customValue="324"/> >> >> >> > On Tuesday, February 8, 2011 8:01:27 AM UTC-6, Adam Tybor wrote: >> >> Its not great but what I have been doing is using includes and redefining >> the include in the application project. You can still define the attribute >> in the library project, you can use simple framelayouts or whatever to >> define a fake placeholder layout in the library project, then in the >> application project define the real view. When compiling the real view in >> the application project it will override the library project. This allows >> the code to compile with the R.syles stuff in the lirbary, yet still have >> the views work too. >> >> Best of luck, its kludgy but workable. >> Adam >> >> << Library >> >> res/values/attrs.xml: >> <resources> >> <declare-styleable name="MyWidget"> >> <attr name="customValue" format="integer"/> >> </declare-styleable> >> </resources> >> >> res/layout/myWidget.xml >> <TextView >> android:id="@+id/my_widget" >> android:layout_width="fill_parent" >> android:layout_height="fill_parent" >> android:text="Replace Me"/> >> >> res/layout/main.xml: >> <?xml version="1.0" encoding="utf-8"?> >> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ >> android" >> android:orientation="vertical" >> android:layout_width="fill_parent" >> android:layout_height="fill_parent" >> > >> <include layout="@layout/myWidget.xml" android:id="@+id/my_widget" /> >> </LinearLayout> >> >> >> << App Project>> >> res/layout/myWidget.xml >> <com.mycompany.test.lib.MyWidget xmlns:android=" >> http://schemas.android.com/apk/res/android" >> xmlns:my="http://schemas.android.com/apk/res/ >> android:id="@+id/my_widget" >> android:layout_width="fill_parent" >> android:layout_height="fill_parent" >> my:customValue="324"/> >> >> >> > On Tuesday, February 8, 2011 8:01:27 AM UTC-6, Adam Tybor wrote: >> >> Its not great but what I have been doing is using includes and redefining >> the include in the application project. You can still define the attribute >> in the library project, you can use simple framelayouts or whatever to >> define a fake placeholder layout in the library project, then in the >> application project define the real view. When compiling the real view in >> the application project it will override the library project. This allows >> the code to compile with the R.syles stuff in the lirbary, yet still have >> the views work too. >> >> Best of luck, its kludgy but workable. >> Adam >> >> << Library >> >> res/values/attrs.xml: >> <resources> >> <declare-styleable name="MyWidget"> >> <attr name="customValue" format="integer"/> >> </declare-styleable> >> </resources> >> >> res/layout/myWidget.xml >> <TextView >> android:id="@+id/my_widget" >> android:layout_width="fill_parent" >> android:layout_height="fill_parent" >> android:text="Replace Me"/> >> >> res/layout/main.xml: >> <?xml version="1.0" encoding="utf-8"?> >> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ >> android" >> android:orientation="vertical" >> android:layout_width="fill_parent" >> android:layout_height="fill_parent" >> > >> <include layout="@layout/myWidget.xml" android:id="@+id/my_widget" /> >> </LinearLayout> >> >> >> << App Project>> >> res/layout/myWidget.xml >> <com.mycompany.test.lib.MyWidget xmlns:android=" >> http://schemas.android.com/apk/res/android" >> xmlns:my="http://schemas.android.com/apk/res/ >> android:id="@+id/my_widget" >> android:layout_width="fill_parent" >> android:layout_height="fill_parent" >> my:customValue="324"/> >> >> >> -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en