Just a thought. I think you need an identifier in your attrs.xml to define
what type is your custom_view (boolean,etc)
On 25 Mar 2012 21:20, "James Su" <[email protected]> wrote:

> Hi all,
>   I'm developing an android application which has a custom view with some
> custom xml attributes. The attributes are defined in res/values/attrs.xml,
> like:
>
> <resources>
>   <declare-styleable name="CustomView">
>     <attr name="custom_attr" />
>   </declare-styleable>
> <resources>
>
> And in CustomView.java, the attributes are loaded with TypedArray, like:
>
> public class CustomView extends View {
>
>     public CustomView(Context context, AttributeSet attrs) {
>         TypedArray a = context.obtainStyledAttributes(attrs,
> R.styleable.CustomView);
>         ...;
>         a.recycle();
> }
>
> This CustomView works correctly in the main apk.
>
> Then I want to write an instrumentation test to test this CustomView, so I
> write a test layout file, which looks like:
>
> tests/res/layout/test-layout.xml:
>
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android";
>     
> xmlns:myapp="http://schemas.android.com/apk/res/com.mycompany.myapp<http://schemas.android.com/apk/res/com.google.android.apps.myapp>"
> >
>
>     <com.google.android.apps.myapp.CustomView
>       android:layout_width="wrap_content"
>       android:layout_height="wrap_content"
>       myapp:custom_attr="xxxx" />
>
> </LinearLayout>
>
> But Eclipse always complains: No resource identifier found for attribute
> 'custom_attr' in package '...'.
>
> I know that in the recent Android SDK r17, a new special xmlns "
> http://schemas.android.com/apk/res-auto"; is introduced to solve this
> issue for library projects, but unfortunately, it doesn't work for my
> case.  Anybody know how to fix this problem?
>
> Best Regards
> James Su
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to