Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin.forms FindViewById<;工具栏>;(Resource.Id.toolbar)返回null_Xamarin.forms_Xamarin.android - Fatal编程技术网

Xamarin.forms FindViewById<;工具栏>;(Resource.Id.toolbar)返回null

Xamarin.forms FindViewById<;工具栏>;(Resource.Id.toolbar)返回null,xamarin.forms,xamarin.android,Xamarin.forms,Xamarin.android,我用这个例子: 但是findviewbyd(Resource.Id.toolbar)返回null。 在新项目中,此示例正在运行。我的项目不起作用。我还能查什么 MainAcitvity.cs protectedoverride void OnCreate(捆绑包) { TabLayoutResource=Resource.Layout.Tabbar; ToolbarResource=Resource.Layout.Toolbar; base.OnCreate(bundle); Xamarin.

我用这个例子:

但是findviewbyd(Resource.Id.toolbar)返回null。 在新项目中,此示例正在运行。我的项目不起作用。我还能查什么

MainAcitvity.cs

protectedoverride void OnCreate(捆绑包)
{
TabLayoutResource=Resource.Layout.Tabbar;
ToolbarResource=Resource.Layout.Toolbar;
base.OnCreate(bundle);
Xamarin.Essentials.Platform.Init(这个包);
Forms.Init(这个,bundle);
CrossCurrentActivity.Current.Init(这个,bundle);
Rg.Plugins.Popup.Popup.Init(这个包);
ToastNotification.Init(本文件);
Xamarin.formsmap.Init(this,bundle);
DependencyService.Register();
加载应用程序(新应用程序());
Toolbar-Toolbar=findviewbyd(Resource.Id.Toolbar);
设置支持操作栏(工具栏);
}
Toolbar.xml


styles.xml


真的
假的
#2196F3
#1976D2
#172239
真的
@样式/应用程序对话框样式
假的
#FF4081
@布局/坡度
下一行

Toolbar toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
您需要将
主页
设置为app.xaml.cs中的导航页面

MainPage = new NavigationPage(new xxxPage());
下一行

Toolbar toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
您需要将
主页
设置为app.xaml.cs中的导航页面

MainPage = new NavigationPage(new xxxPage());
Android.Support.V7.Widget.Toolbar toolbar  = this.FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
MainPage = new NavigationPage(new xxxPage());