Я продолжаю получать это:
Ссылка на объект не установлена на экземпляр объекта Ошибка при развертывании моего приложения xamarin. Я пытаюсь использовать панель инструментов Support v7 AppCompat.
Это мой код:
using Android.App;
using Android.Widget;
using Android.OS;
using Android.Support.V7.App;
using SupportToolbar = Android.Support.V7.Widget.Toolbar;
namespace PoetreeFinal
{
[Activity(Label = "poetree", MainLauncher = true, Theme ="@style/PoetreeTheme")]
public class MainActivity : AppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SupportToolbar toolbar = FindViewById<SupportToolbar>(Resource.Id.toolBar);
SetSupportActionBar(toolbar);
SupportActionBar.Title = "Home";
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
}
}
}
Но при развертывании я получаю эту ошибку:
Моя панель инструментов выглядит так:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="@color/primary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
И мой основной макет:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/primary"
android:orientation="vertical">
<include
layout="@layout/toolbar" />
<RelativeLayout
android:id="@+id/foreground"
android:background="@android:color/white"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Любая помощь в устранении этой ошибки будет принята с благодарностью.