Domanda

ho customview, voglio aggiungerlo nel file xml che ho provato in questo modo ma ricevo questo errore

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

questo è l'xml che sto usando ..

 <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>
È stato utile?

Soluzione

Aggiungi il costruttore:

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

    //TODO:
}

alla tua classe di visualizzazione personalizzata.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top