开发者

About extending LinearLayout

开发者 https://www.devze.com 2023-03-04 23:27 出处:网络
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

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".

0

精彩评论

暂无评论...
验证码 换一张
取 消