Custom XML attributes for imported custom view

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Custom XML attributes for imported custom view

Postby jmar777 » Fri Sep 12, 2008 9:06 pm

I am playing around with custom views and would like to include them in an external library (jar) for the sake of re-usability. I am trying to create some custom attributes for these views that can be set declaratively in the xml.

I have taken a look at the closely related tutorial on PocketBook ( ... urce-files - forum won't let me use URL tag on first post?), but from what I can tell it only applies to custom views that exist within an Android project.

Since I am trying to develop these views in an external library, the tutorial hasn't directly related to my situation. Therefore, when I am using one of these imported custom views in an Android project, I can't get the ADT to recognize the custom attributes.

For example, if I put the following in my main.xml:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <LinearLayout xmlns:android=""
  2.         xmlns:m=""
  3.    android:orientation="vertical"
  4.    android:layout_width="fill_parent"
  5.    android:layout_height="wrap_content"
  6.         >
  7.         <
  8.                 android:layout_width="fill_parent"
  9.                 android:layout_height="wrap_content"
  10.                 android:text="0.00"
  11.                 android:textColor="#222244"
  12.                 m:keypadBackgroundDrawable="@drawable/popup_bg"
  13.                 />
  14. </LinearLayout>
Parsed in 0.001 seconds, using GeSHi

... I get an error stating "No resource identifier found for attribute 'keypadBackgroundDrawable' in package '"

To be honest, I am completely clueless as to where android looks to locate the custom attributes. I have tried including an inside of the package, but either it was formatted incorrectly, or this is the wrong place. Here are the contents of the file:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package;
  3. public final class R {
  4.         /**
  5.          * Custom xml attributes for custom widgets
  6.          */
  7.         public static final class attr {
  8.                 public static final int keypadBackgroundDrawable=0x7f010000;
  9.         }
  11.     public static final class styleable {
  12.         public static final int[] NumberPadEditText = {
  13.             0x7f010000
  14.         };
  15.         public static final int NumberPadEditText_keypadBackgroundDrawable = 0;
  16.     };
  17. }
Parsed in 0.011 seconds, using GeSHi

I was assuming that since generally contains resource identifiers, that this is where android would be looking. I have a suspicion I'm on the wrong track altogether though - any pointers would be much appreciated!
Posts: 2
Joined: Fri Sep 12, 2008 8:36 pm


Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 10 guests