Skip to content

Commit 02b143a

Browse files
committed
[working-with] navigation XF 1.3
1 parent c64ed57 commit 02b143a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+894
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Any raw assets you want to be deployed with your application can be placed in
2+
this directory (and child directories) and given a Build Action of "AndroidAsset".
3+
4+
These files will be deployed with your package and will be accessible using Android's
5+
AssetManager, like this:
6+
7+
public class ReadAsset : Activity
8+
{
9+
protected override void OnCreate (Bundle bundle)
10+
{
11+
base.OnCreate (bundle);
12+
13+
InputStream input = Assets.Open ("my_asset.txt");
14+
}
15+
}
16+
17+
Additionally, some Android functions will automatically load asset files:
18+
19+
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
3+
using Android.App;
4+
using Android.Content;
5+
using Android.Content.PM;
6+
using Android.Runtime;
7+
using Android.Views;
8+
using Android.Widget;
9+
using Android.OS;
10+
11+
namespace WorkingWithNavigation.Droid
12+
{
13+
[Activity (Label = "WorkingWithNavigation.Droid", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
14+
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
15+
{
16+
protected override void OnCreate (Bundle bundle)
17+
{
18+
base.OnCreate (bundle);
19+
20+
global::Xamarin.Forms.Forms.Init (this, bundle);
21+
22+
LoadApplication (new App ());
23+
}
24+
}
25+
}
26+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
<uses-sdk android:minSdkVersion="15" />
4+
<application>
5+
</application>
6+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using Android.App;
4+
5+
// Information about this assembly is defined by the following attributes.
6+
// Change them to the values specific to your project.
7+
8+
[assembly: AssemblyTitle ("WorkingWithNavigation.Droid")]
9+
[assembly: AssemblyDescription ("")]
10+
[assembly: AssemblyConfiguration ("")]
11+
[assembly: AssemblyCompany ("")]
12+
[assembly: AssemblyProduct ("")]
13+
[assembly: AssemblyCopyright ("craigdunn")]
14+
[assembly: AssemblyTrademark ("")]
15+
[assembly: AssemblyCulture ("")]
16+
17+
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
18+
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
19+
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
20+
21+
[assembly: AssemblyVersion ("1.0.0")]
22+
23+
// The following attributes are used to specify the signing key for the assembly,
24+
// if desired. See the Mono documentation for more information about signing.
25+
26+
//[assembly: AssemblyDelaySign(false)]
27+
//[assembly: AssemblyKeyFile("")]
28+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Images, layout descriptions, binary blobs and string dictionaries can be included
2+
in your application as resource files. Various Android APIs are designed to
3+
operate on the resource IDs instead of dealing with images, strings or binary blobs
4+
directly.
5+
6+
For example, a sample Android app that contains a user interface layout (main.axml),
7+
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
8+
would keep its resources in the "Resources" directory of the application:
9+
10+
Resources/
11+
drawable/
12+
icon.png
13+
14+
layout/
15+
main.axml
16+
17+
values/
18+
strings.xml
19+
20+
In order to get the build system to recognize Android resources, set the build action to
21+
"AndroidResource". The native Android APIs do not operate directly with filenames, but
22+
instead operate on resource IDs. When you compile an Android application that uses resources,
23+
the build system will package the resources for distribution and generate a class called "R"
24+
(this is an Android convention) that contains the tokens for each one of the resources
25+
included. For example, for the above Resources layout, this is what the R class would expose:
26+
27+
public class R {
28+
public class drawable {
29+
public const int icon = 0x123;
30+
}
31+
32+
public class layout {
33+
public const int main = 0x456;
34+
}
35+
36+
public class strings {
37+
public const int first_string = 0xabc;
38+
public const int second_string = 0xbcd;
39+
}
40+
}
41+
42+
You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
43+
to reference the layout/main.axml file, or R.strings.first_string to reference the first
44+
string in the dictionary file values/strings.xml.
Loading
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
7+
<ProjectGuid>{6823C036-7A3F-47B4-8FAC-DA16FFA9786E}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<RootNamespace>WorkingWithNavigation.Droid</RootNamespace>
10+
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
11+
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
12+
<AndroidResgenClass>Resource</AndroidResgenClass>
13+
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
14+
<AndroidApplication>True</AndroidApplication>
15+
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
16+
<AssemblyName>WorkingWithNavigation.Droid</AssemblyName>
17+
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
18+
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
19+
</PropertyGroup>
20+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
21+
<DebugSymbols>true</DebugSymbols>
22+
<DebugType>full</DebugType>
23+
<Optimize>false</Optimize>
24+
<OutputPath>bin\Debug</OutputPath>
25+
<DefineConstants>DEBUG;</DefineConstants>
26+
<ErrorReport>prompt</ErrorReport>
27+
<WarningLevel>4</WarningLevel>
28+
<AndroidLinkMode>None</AndroidLinkMode>
29+
<ConsolePause>false</ConsolePause>
30+
</PropertyGroup>
31+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
32+
<DebugType>full</DebugType>
33+
<Optimize>true</Optimize>
34+
<OutputPath>bin\Release</OutputPath>
35+
<ErrorReport>prompt</ErrorReport>
36+
<WarningLevel>4</WarningLevel>
37+
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
38+
<ConsolePause>false</ConsolePause>
39+
</PropertyGroup>
40+
<ItemGroup>
41+
<Reference Include="System" />
42+
<Reference Include="System.Xml" />
43+
<Reference Include="System.Core" />
44+
<Reference Include="Mono.Android" />
45+
<Reference Include="Xamarin.Android.Support.v4">
46+
<HintPath>..\packages\Xamarin.Android.Support.v4.19.1.0\lib\MonoAndroid10\Xamarin.Android.Support.v4.dll</HintPath>
47+
</Reference>
48+
<Reference Include="Xamarin.Forms.Platform.Android">
49+
<HintPath>..\packages\Xamarin.Forms.1.3.1.6296\lib\MonoAndroid10\Xamarin.Forms.Platform.Android.dll</HintPath>
50+
</Reference>
51+
<Reference Include="FormsViewGroup">
52+
<HintPath>..\packages\Xamarin.Forms.1.3.1.6296\lib\MonoAndroid10\FormsViewGroup.dll</HintPath>
53+
</Reference>
54+
<Reference Include="Xamarin.Forms.Core">
55+
<HintPath>..\packages\Xamarin.Forms.1.3.1.6296\lib\MonoAndroid10\Xamarin.Forms.Core.dll</HintPath>
56+
</Reference>
57+
<Reference Include="Xamarin.Forms.Xaml">
58+
<HintPath>..\packages\Xamarin.Forms.1.3.1.6296\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll</HintPath>
59+
</Reference>
60+
</ItemGroup>
61+
<ItemGroup>
62+
<ProjectReference Include="..\WorkingWithNavigation\WorkingWithNavigation.csproj">
63+
<Project>{A129851A-DC77-42FD-8EDF-D07C294DD965}</Project>
64+
<Name>WorkingWithNavigation</Name>
65+
</ProjectReference>
66+
</ItemGroup>
67+
<ItemGroup>
68+
<Compile Include="MainActivity.cs" />
69+
<Compile Include="Resources\Resource.designer.cs" />
70+
<Compile Include="Properties\AssemblyInfo.cs" />
71+
</ItemGroup>
72+
<ItemGroup>
73+
<None Include="Resources\AboutResources.txt" />
74+
<None Include="Properties\AndroidManifest.xml" />
75+
<None Include="Assets\AboutAssets.txt" />
76+
<None Include="packages.config" />
77+
</ItemGroup>
78+
<ItemGroup>
79+
<Folder Include="Resources\layout\" />
80+
<Folder Include="Resources\values\" />
81+
</ItemGroup>
82+
<ItemGroup>
83+
<AndroidResource Include="Resources\drawable\icon.png" />
84+
<AndroidResource Include="Resources\drawable-hdpi\icon.png" />
85+
<AndroidResource Include="Resources\drawable-xhdpi\icon.png" />
86+
<AndroidResource Include="Resources\drawable-xxhdpi\icon.png" />
87+
</ItemGroup>
88+
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
89+
<Import Project="..\packages\Xamarin.Forms.1.3.1.6296\build\portable-win+net45+wp80+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\packages\Xamarin.Forms.1.3.1.6296\build\portable-win+net45+wp80+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
90+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Xamarin.Android.Support.v4" version="19.1.0" targetFramework="MonoAndroid50" />
4+
<package id="Xamarin.Forms" version="1.3.1.6296" targetFramework="MonoAndroid50" />
5+
</packages>

WorkingWithNavigation/Metadata.xml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<SampleMetadata>
3+
<ID>4bf9e7e7-1359-4bbb-851d-7aa17eaf8945</ID>
4+
<IsFullApplication>false</IsFullApplication>
5+
<Level>Beginner</Level>
6+
<Tags>User Interface, Xamarin.Forms</Tags>
7+
<SupportedPlatforms>iOS, Android, Windows</SupportedPlatforms>
8+
<LicenseRequirement>Indie</LicenseRequirement>
9+
<Gallery>false</Gallery>
10+
<Brief>This sample demonstrates how to work with Navigation push/pop using Xamarin Forms 1.3.</Brief>
11+
</SampleMetadata>

WorkingWithNavigation/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Working with Navigation
2+
==============
3+
4+
This sample relates to the [Working with Navigation in Xamarin.Forms (1.3)](http://developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/navigation) doc.
5+
6+
![screenshot](https://raw.githubusercontent.com/xamarin/xamarin-forms-samples/master/WorkingWithNativation/Screenshots/navigation-ios.png "Navigation")
7+
8+
![screenshot](https://raw.githubusercontent.com/xamarin/xamarin-forms-samples/master/WorkingWithNativation/Screenshots/navigation-android.png "Navigation")
9+
10+
Author
11+
------
12+
13+
Craig Dunn
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2012
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkingWithNavigation", "WorkingWithNavigation\WorkingWithNavigation.csproj", "{A129851A-DC77-42FD-8EDF-D07C294DD965}"
5+
EndProject
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkingWithNavigation.iOS", "iOS\WorkingWithNavigation.iOS.csproj", "{DE6A5A09-B70F-427C-B78D-7C2E10BAB740}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkingWithNavigation.Droid", "Droid\WorkingWithNavigation.Droid.csproj", "{6823C036-7A3F-47B4-8FAC-DA16FFA9786E}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
Debug|iPhoneSimulator = Debug|iPhoneSimulator
15+
Release|iPhoneSimulator = Release|iPhoneSimulator
16+
Debug|iPhone = Debug|iPhone
17+
Release|iPhone = Release|iPhone
18+
Ad-Hoc|iPhone = Ad-Hoc|iPhone
19+
AppStore|iPhone = AppStore|iPhone
20+
EndGlobalSection
21+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
22+
{6823C036-7A3F-47B4-8FAC-DA16FFA9786E}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU
23+
{6823C036-7A3F-47B4-8FAC-DA16FFA9786E}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU
24+
{6823C036-7A3F-47B4-8FAC-DA16FFA9786E}.AppStore|iPhone.ActiveCfg = Release|Any CPU
25+
{6823C036-7A3F-47B4-8FAC-DA16FFA9786E}.AppStore|iPhone.Build.0 = Release|Any CPU
26+
{6823C036-7A3F-47B4-8FAC-DA16FFA9786E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{6823C036-7A3F-47B4-8FAC-DA16FFA9786E}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{6823C036-7A3F-47B4-8FAC-DA16FFA9786E}.Debug|iPhone.ActiveCfg = Debug|Any CPU
29+
{6823C036-7A3F-47B4-8FAC-DA16FFA9786E}.Debug|iPhone.Build.0 = Debug|Any CPU
30+
{6823C036-7A3F-47B4-8FAC-DA16FFA9786E}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
31+
{6823C036-7A3F-47B4-8FAC-DA16FFA9786E}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
32+
{6823C036-7A3F-47B4-8FAC-DA16FFA9786E}.Release|Any CPU.ActiveCfg = Release|Any CPU
33+
{6823C036-7A3F-47B4-8FAC-DA16FFA9786E}.Release|Any CPU.Build.0 = Release|Any CPU
34+
{6823C036-7A3F-47B4-8FAC-DA16FFA9786E}.Release|iPhone.ActiveCfg = Release|Any CPU
35+
{6823C036-7A3F-47B4-8FAC-DA16FFA9786E}.Release|iPhone.Build.0 = Release|Any CPU
36+
{6823C036-7A3F-47B4-8FAC-DA16FFA9786E}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
37+
{6823C036-7A3F-47B4-8FAC-DA16FFA9786E}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
38+
{A129851A-DC77-42FD-8EDF-D07C294DD965}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
39+
{A129851A-DC77-42FD-8EDF-D07C294DD965}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
40+
{A129851A-DC77-42FD-8EDF-D07C294DD965}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
41+
{A129851A-DC77-42FD-8EDF-D07C294DD965}.AppStore|iPhone.Build.0 = Debug|Any CPU
42+
{A129851A-DC77-42FD-8EDF-D07C294DD965}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
43+
{A129851A-DC77-42FD-8EDF-D07C294DD965}.Debug|Any CPU.Build.0 = Debug|Any CPU
44+
{A129851A-DC77-42FD-8EDF-D07C294DD965}.Debug|iPhone.ActiveCfg = Debug|Any CPU
45+
{A129851A-DC77-42FD-8EDF-D07C294DD965}.Debug|iPhone.Build.0 = Debug|Any CPU
46+
{A129851A-DC77-42FD-8EDF-D07C294DD965}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
47+
{A129851A-DC77-42FD-8EDF-D07C294DD965}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
48+
{A129851A-DC77-42FD-8EDF-D07C294DD965}.Release|Any CPU.ActiveCfg = Release|Any CPU
49+
{A129851A-DC77-42FD-8EDF-D07C294DD965}.Release|Any CPU.Build.0 = Release|Any CPU
50+
{A129851A-DC77-42FD-8EDF-D07C294DD965}.Release|iPhone.ActiveCfg = Release|Any CPU
51+
{A129851A-DC77-42FD-8EDF-D07C294DD965}.Release|iPhone.Build.0 = Release|Any CPU
52+
{A129851A-DC77-42FD-8EDF-D07C294DD965}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
53+
{A129851A-DC77-42FD-8EDF-D07C294DD965}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
54+
{DE6A5A09-B70F-427C-B78D-7C2E10BAB740}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone
55+
{DE6A5A09-B70F-427C-B78D-7C2E10BAB740}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone
56+
{DE6A5A09-B70F-427C-B78D-7C2E10BAB740}.AppStore|iPhone.ActiveCfg = AppStore|iPhone
57+
{DE6A5A09-B70F-427C-B78D-7C2E10BAB740}.AppStore|iPhone.Build.0 = AppStore|iPhone
58+
{DE6A5A09-B70F-427C-B78D-7C2E10BAB740}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
59+
{DE6A5A09-B70F-427C-B78D-7C2E10BAB740}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
60+
{DE6A5A09-B70F-427C-B78D-7C2E10BAB740}.Debug|iPhone.ActiveCfg = Debug|iPhone
61+
{DE6A5A09-B70F-427C-B78D-7C2E10BAB740}.Debug|iPhone.Build.0 = Debug|iPhone
62+
{DE6A5A09-B70F-427C-B78D-7C2E10BAB740}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
63+
{DE6A5A09-B70F-427C-B78D-7C2E10BAB740}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
64+
{DE6A5A09-B70F-427C-B78D-7C2E10BAB740}.Release|Any CPU.ActiveCfg = Release|iPhoneSimulator
65+
{DE6A5A09-B70F-427C-B78D-7C2E10BAB740}.Release|Any CPU.Build.0 = Release|iPhoneSimulator
66+
{DE6A5A09-B70F-427C-B78D-7C2E10BAB740}.Release|iPhone.ActiveCfg = Release|iPhone
67+
{DE6A5A09-B70F-427C-B78D-7C2E10BAB740}.Release|iPhone.Build.0 = Release|iPhone
68+
{DE6A5A09-B70F-427C-B78D-7C2E10BAB740}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
69+
{DE6A5A09-B70F-427C-B78D-7C2E10BAB740}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
70+
EndGlobalSection
71+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
3+
using Xamarin.Forms;
4+
5+
namespace WorkingWithNavigation
6+
{
7+
public class App : Application
8+
{
9+
public App ()
10+
{
11+
var np = new NavigationPage (new Page1()) {Title="Navigation Stack"};
12+
13+
// The root page of your application
14+
MainPage = np;
15+
}
16+
17+
protected override void OnStart ()
18+
{
19+
// Handle when your app starts
20+
}
21+
22+
protected override void OnSleep ()
23+
{
24+
// Handle when your app sleeps
25+
}
26+
27+
protected override void OnResume ()
28+
{
29+
// Handle when your app resumes
30+
}
31+
}
32+
}
33+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
3+
using Xamarin.Forms;
4+
5+
namespace WorkingWithNavigation
6+
{
7+
public class Page1 : ContentPage
8+
{
9+
public Page1 ()
10+
{
11+
var b = new Button { Text = "Next" };
12+
b.Clicked += async (sender, e) => {
13+
await Navigation.PushAsync (new Page2());
14+
};
15+
Title = "Page 1";
16+
Content = new StackLayout {
17+
BackgroundColor = Color.Red,
18+
Children = {
19+
new Label { Text = "Page 1", FontSize=Device.GetNamedSize(NamedSize.Large, typeof(Label)) }
20+
, b
21+
}
22+
};
23+
}
24+
}
25+
}
26+
27+

0 commit comments

Comments
 (0)