Recently Android Studio shows me a warning in the onClick element of my xml views.
Use databinding or explicit wiring of click listener in code
Suppress Add tools:ignore="UsingOnClickInXml" attribute
This is my View:
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center"
android:scaleType="fitCenter"
android:src="@drawable/ic_web_white_24dp"
android:clickable="true"
android:focusable="true"
android:onClick="openSite" />
What is the meaning of the warning? What's wrong in using android:onClick?
Edit: I know the difference between setting the onClick on xml and declaring the onClickListener in the Activity but I want to know why the last one is preferable.