Fehler beim Erstellen der benutzerdefinierten Ansicht
-
27-10-2019 - |
Frage
Ich habe Customview, ich möchte das in der XML-Datei hinzufügen, die ich so versucht habe, aber ich erhalte diesen Fehler
Custom view TouchImageView is not using the 2- or 3-argument View constructors;
XML attributes will not work
Dies ist die XML, die ich verwende.
<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>
Lösung
Fügen Sie den Konstruktor hinzu:
public TouchImageView(Context context, AttributeSet attributeSet)
{
super(context, attributeSet);
//TODO:
}
zu Ihrer benutzerdefinierten View-Klasse.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow