It's very simple, override the 3 following methods:

   @Override
    public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) {
        return new CellLayout.LayoutParams(getContext(), attrs);
    }

    @Override
    protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
        return p instanceof CellLayout.LayoutParams;
    }

    @Override
    protected ViewGroup.LayoutParams
generateLayoutParams(ViewGroup.LayoutParams p) {
        return new CellLayout.LayoutParams(p);
    }

Also, the styleable name for your layout params should follow our
convention and be called MyLayout_Layout. The attributes should be
called layout_myattribute. The complete name of an attribute is:

my.app.R.styleable.MyLayout_Layout_layout_myattribute

On Mon, Sep 1, 2008 at 2:13 PM, Erik Calissendorff
<[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I have created a custom ViewGroup and would like to have a custom
> LayoutParams together with it so I can assign these to the children
> through the XML.
>
> I have created a custom LayoutParams class and added the following to
> my attrs.xml:
> <declare-styleable name="LayoutParams">
>        <attr name="column_span" format="integer" />
>        <attr name="row_span" format="integer" />
> </declare-styleable>
>
> I can use the xml tags in my children from my layout.xml with:
>                app:column_span="2"
>                app:row_span="2"
>
> But I do not understand how the inflate process should be able to
> understand that it should create my type of LayoutParams (it doesn't
> at the moment). If I only had my own type of children I could override
> the inflate process, but that can't be the preferred way?
>
> Any ideas how I correctly should create my own ViewGroup with
> associated LayoutParams that can be used from xml?
> >
>



-- 
Romain Guy
www.curious-creature.org

--~--~---------~--~----~------------~-------~--~----~
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]
Announcing the new Android 0.9 SDK beta!
http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to