I am fairly new to Xamarin and XML although I have experience with C#. I have created a tabbed page in xml and it isn't displaying at all 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>
I have 2 tabbedpage children (Home and Add Location) I want the Home page to be the default page, although even the TabbedPage won't show up and the app is blank.
Home.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);
}
}
}
Thanks,
Matt
Your MainActivity.cs isn't setup to support Xamarin Forms, its loading the view natively. Change your MainActivity.cs to this:
using Android.App; using Android.Widget; using Android.OS;
You will also need to create a file call styles.xml in your Resources > Values folder and add this theme in.
If you want to see an example you can have a look at https://github.com/exrin/ExrinSample/blob/master/Exrin-Sample/ExrinSample.Droid/MainActivity.cs