创建自定义视图时出现错误

3
我有一个自定义视图,我想将其添加到xml文件中。我尝试了以下方式,但是出现了错误。
  Custom view TouchImageView is not using the 2- or 3-argument View constructors;
  XML attributes will not work

这是我使用的XML文件...
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

 <view 
   class="com.zoom.TouchImageView"
   android:id="@+id/webView1"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent" />

</LinearLayout>

请澄清您的问题。 - Awais Tariq
@AwaisTariq 我在 XML 图形布局中遇到了问题。 - NagarjunaReddy
1个回答

16

添加构造函数:

public TouchImageView(Context context, AttributeSet attributeSet)
{
    super(context, attributeSet);

    //TODO:
}

添加到你自定义的 View 类中。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接