I have a layout in XML as follows:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:onClick="myButton.performClick" />
myButton is a member of this activity, is it possible use a class member method here?
No, as the docs say (emphasis mine):
If you wanted to execute a method on a field, you could wrap it I suppose.
Then:
but that almost defeats the purpose of the XML
onClickattribute (making things more concise). Is there a good reason forperformClickto be on your button instead of your activity anyway?Lastly, doing this on the LinearLayout is fine. The attribute is supported for all Views.