Hi guys,

I'll to expose my trouble here. I'm convinced that I could do the same
thing in another way, but I would like to know if my approach is
correct as well.

I want to build a custom class that extends RelativeLayout and
implements a Interface MyInterface.

I have the complete definition of the layout in a xml. I'm try to
separate the code from xml to gain flexibility. I think that an
example is clearer.

I have:

public class MyLayoutView extends RelativeLayout implements
MyInterface {

    private Context context;
    private ViewGroup parent;

    AlarmItemView(Context context, ViewGroup parent) {
        super(context);

        this.parent = parent;
        this.context = context;

        // here i'm trying to get the layout_width and layout_height
from the xml and assign them to this istance

        XmlPullParser parser =
context.getResources().getXml(R.layout.alarm_item_view); //good
        int count = parser.getAttributeCount(); //count is always -1
        AttributeSet attributes = Xml.asAttributeSet(parser); // good
(but wrong I guess)
        LayoutParams params = generateLayoutParams(attributes); //
Exception!
        setLayoutParams(params);

    }

    /*
     *
         MyInterface and other suff methods
     *
     */

}

So,the question is:

"Is there a way to get android:XXX param from xml e assign them via
code?"

Thanks!!

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

Reply via email to