2011-05-11 79 views
1

我需要创建一个View,它扩展了LinearLayout以包含一些标准的Android小部件。 我创建了一个扩展LinearLayout类的类MyLinearLayout;但现在,我怎样才能将它用作xml布局文件中的一个元素?我无法得到它的工作,我一直无法找到它的信息,所以我有点困惑... O.O关于扩展LinearLayout

回答

2

假设

package com.example; 

public class MyLinearLayout extends LinearLayout... 
在XML

可以使用

<com.example.MyLinearLayout 
    android:id="@+id/MyLayout" 
    [rest of attributes go here] 
> 
[other stuff here] 
</com.example.MyLinearLayout> 
1

你必须用你正在使用的软件包名称作为前言。因此,不是声明“MyLinearLayout”,而是声明“[PackageName] .MyLinearLayout”。