I am still training with Xamarin. Now I got issue that I cannot set object to resource and I am getting this error: reference not set to an instance of object.
What I have done, that I created Activity class. There I create LinearLayout object. Idea is when I click on blue zone object then swipes to another page: vehicle not parked layout. But it doesn't work, I am getting errors. This is my ZonesActivity class:
namespace CustomActionBarParking
{
[Activity(Label = "@+id/blueZoneLayout")]
public class ZonesActivity : Activity
LinearLayout mBlueZone;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
mBlueZone = FindViewById<LinearLayout>(Resource.Id.blueZoneLayout);
if (mBlueZone != null)
{
mBlueZone.Click += (object sender, EventArgs args) =>
{
SetContentView(Resource.Layout.vehicle_not_parked);
};
}
else
{
throw new ArgumentException("Parameter cannot be null", "");
}
}}}
And this is my part of zones_list.axml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="100">
<LinearLayout
android:orientation="horizontal"
android:layout_weight="11"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/blueZoneLayout"
android:weightSum="100"
android:focusableInTouchMode="true"
android:background="@android:color/background_light">
<TextView
android:text="M"
android:layout_weight="10"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/textView2"
android:textColor="@android:color/holo_blue_dark"
android:gravity="center" />
<TextView
android:text="Blue zone"
android:layout_weight="80"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/textView3"
android:textColor="@android:color/holo_blue_dark"
android:gravity="center" />
<TextView
android:text="i"
android:layout_weight="10"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/textView4"
android:textColor="@android:color/holo_blue_dark"
android:gravity="center" />
</LinearLayout>
Any ideas why I can't set references to this object's? And also I want to mention that I am calling zones_list layout from MainActivity.cs . Edit: In throw new ArgumentException I am getting this:
Unhandled Exception:
System.ArgumentException: Parameter cannot be null