Check out Api Demos, there is a Custom View example.  Basically, you need a
constructor that has this signature:

    public LabelView(Context context, AttributeSet attrs) {

and in your XML:

    <com.example.android.apis.view.LabelView
            android:background="@drawable/red"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            app:text="Red"/>

jason

On Fri, Oct 31, 2008 at 1:49 PM, Mark Wyszomierski <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> How do we construct an instance of a View derived class from an XML
> resource? I have something like:
>
>    public class MyView extends View
>    {
>        public MyView(Context context)
>        {
>            super(context);
>        }
>    }
>
> How can we construct the class from an XML resource file? I want to
> add some buttons etc, then use them in the view class.
>
> Thanks
> >
>

--~--~---------~--~----~------------~-------~--~----~
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