I need to create a View which extends a LinearLayout to contain some standard android widget. I've created a class MyLinearLayout which extends the LinearLayout class; but now, how can I use it as an element in the xml layout file? I can't get it working and I haven't been able to find info about it and so I'm a bit confused...开发者_StackOverflow O.O
Assuming
package com.example;
public class MyLinearLayout extends LinearLayout...
in your xml you can use
<com.example.MyLinearLayout
android:id="@+id/MyLayout"
[rest of attributes go here]
>
[other stuff here]
</com.example.MyLinearLayout>
You have to preface it with the package name that you are using. So, instead of declaring "MyLinearLayout" you would declare "[PackageName].MyLinearLayout".
精彩评论