Color isn't a class, so, ofcourse, you can't instantiate it from xml.

The way I see this happening would be Implementing your own View:
RectangleView. Have it extend View and have it draw a rectangle, using
the settings from the xml.
Or you could extend a ViewGroup and implement your own, so other View
will become part of this ViewGroup. This might be more resource
friendly.

On 26 apr, 06:09, Lucius Fox <[email protected]> wrote:
> Hi,
>
> I am trying to draw a rectangle using layout.xml file without java
> code.  So this is what I tried:
>
> <LinearLayout>
> <color
>                 android:layout_width="wrap_content"
>                 android:layout_height="10dp"
>                 android:color="#00ff00"
>                 />
>
>         </LinearLayout>
> But I get these error when i run it in emulator:
>
> E/AndroidRuntime(  760): Caused by: java.lang.ClassNotFoundException:
> android.view.color in loader dalvik.system.pathclassloa...@435c9be8
> E/AndroidRuntime(  760):        at
> dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
> E/AndroidRuntime(  760):        at
> java.lang.ClassLoader.loadClass(ClassLoader.java:573)
> E/AndroidRuntime(  760):        at
> java.lang.ClassLoader.loadClass(ClassLoader.java:532)
> E/AndroidRuntime(  760):        at
> android.view.LayoutInflater.createView(LayoutInflater.java:465)
> E/AndroidRuntime(  760):        at
> android.view.LayoutInflater.onCreateView(LayoutInflater.java:543)
> E/AndroidRuntime(  760):        at 
> com.android.internal.policy.impl.PhoneLayoutInfl
>
> Can you please tell me how can I do it?
--~--~---------~--~----~------------~-------~--~----~
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