MonoDroid onClick From XML No such method error
LiftInspection.axml
<Button
android:id="@+id/expandCollapse1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/expand_arrow"
android:text="Function/Controls"
android:textSize="20sp"
android:textColor="@android:color/white"
android:background="@drawable/expandCollapseButton"
android:gravity="center"
android:onClick="button_Click"/>
LiftInspection.cs
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.LiftInspection);
}
public void button_Click(View view)
{
Toast.MakeText(this, "Testing", ToastLength.Long).Show();
}
As soon as I press the button, the app crashes and exits. In Android Log I found "java.lang.IllegalStateException: Could not find button_Click (View) method in activity class cpecfieldapp.LiftInspection for onClick handler in view class android.widget.Button with id'expandCollapse1 '"
Everything I found when setting up a click event from xml only shows what I am doing. By putting it in android: onClick from XML and having a public void where the only parameter is the view in the action that implements that layout. What am I missing?
+3
source to share
3 answers
This is not something that is supported in the current version of Mono for Android. You can learn more about this in this bug report .
+3
source to share