尽管我有使用 C# 的经验,但我对 Xamarin 和 XML 还是很陌生。我在 xml 中创建了一个选项卡式页面,但它根本没有显示Main.axml:
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:mypages="clr-namespace:MainActivity.Pages;assembly=MainActivity"
x:Class="MainActivity.tabPages">
<TabbedPage.Children>
<mypages:Home />
<mypages:AddLocation />
</TabbedPage.Children>
</TabbedPage>
我有 2 个子标签页(主页和添加位置) 我希望主页成为默认页面,尽管即使是 TabbedPage 也不会显示并且应用程序是空白的。
主页.axml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MainActivity.ActualPage" Title="Home" BackgroundColor="Green">
<ContentPage.Content>
<Label Text="Hi there from Page 1" TextColor="White" Font="20"
VerticalOptions="Center" HorizontalOptions="Center" />
</ContentPage.Content>
</ContentPage>
MainActivity.cs:
using Android.App;
using Android.Widget;
using Android.OS;
namespace Xonify
{
[Activity(Label = "App", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView (Resource.Layout.Main);
}
}
}
谢谢,
马特