Implementieren onClick nur für eine TextView Verbindung drawable

Ich muss ein text mit einem drawable auf der linken Seite, und ich möchte ausführen von code, wenn der Benutzer auf/berührt das Bild (nur das Bild, nicht den text), so habe ich ein LinearLayout mit einer TextView und ein Bildansicht das ist anklickbar und führt zu einem onClick-Ereignis. Der XML-parser schlägt vor, mich zu ersetzen, dies mit einem TextView mit einer Verbindung drawable, die ziehen würde, das gleiche mit viel weniger Zeilen XML.. Meine Frage ist "kann ich angeben, ich will Griff ein onClick-Ereignis nur auf das drawable des TextView und nicht auf die TextView selbst? Ich habe einige Lösungen gesehen, die beinhaltet das schreiben von eigenen Erweiterung TextView, aber ich bin nur daran interessiert ist, in der Lage, es zu tun in der layout Ressource, wenn möglich, ansonsten behalte ich die folgenden XML code:

<LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="horizontal" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="bottom"
            android:paddingTop="10dp"
            android:paddingLeft="10dp"
            android:paddingRight="10dp"
            android:text="@string/home_feedback_title"
            android:textColor="@android:color/primary_text_dark"
            android:textStyle="bold" 
            android:paddingBottom="4dp"/>


        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/action_feedback" 
            android:clickable="true"
            android:onClick="onClickFeedback"
            android:contentDescription="@string/action_feedback_description"/>
</LinearLayout>
Schreibe einen Kommentar