Image button showing Unhandled exception error.

Hi,

I am new to xamarin android . i am using image button . it is showing "Unhandled exception Error" message. Error Message is

**Unhandled Exception:

System.NullReferenceException: Object reference not set to an instance of an object. occurred**

My code is:

  <ImageButton
   android:id="@+id/button1"
   android:src="@drawable/testbutton"
   android:layout_width="225dp"
   android:layout_height="225dp"
   android:layout_below="@+id/testbtn"
   android:layout_marginTop="40dp"
   android:background="#dbe8ff"
   android:layout_centerHorizontal="true" />

   ImageButton button2 = FindViewById<ImageButton>(Resource.Id.button1);
   button2.Click += Button2_Click;

Please help me to resolve this.

Answers

Sign In or Register to comment.