Error in creation of custom view

爷,独闯天下 提交于 2019-12-06 08:38:35

问题


i have customview, i want to add that in the xml file i tried like this but i am getting this error

  Custom view TouchImageView is not using the 2- or 3-argument View constructors;
  XML attributes will not work

this is the xml i am using..

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

回答1:


Add the constructor:

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

    //TODO:
}

to your custom View class.



来源:https://stackoverflow.com/questions/8352249/error-in-creation-of-custom-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!