-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMainActivity.cs
49 lines (39 loc) · 1.28 KB
/
MainActivity.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using Android.App;
using Android.OS;
using Android.Support.V4.App;
using FormsEmbeddingPreview;
using FormsEmbeddingPreview.Droid;
using TipCalc;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using FragmentTransaction = Android.Support.V4.App.FragmentTransaction;
using Fragment = Android.Support.V4.App.Fragment;
using Button = Android.Widget.Button;
using Resource = FormsEmbeddingPreview.Droid.Resource;
namespace FormsEmbeddingPreview.Droid
{
[Activity(Label = "FormsEmbedding.Droid", MainLauncher = true)]
public class MainActivity : FragmentActivity
{
Fragment _tipCalc;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Before the first time we use it, we need to initialize Xamarin.Forms
Forms.Init(this, null);
SetContentView(Resource.Layout.Main);
var ft = SupportFragmentManager.BeginTransaction();
ft.Replace(Resource.Id.fragment_frame_layout, new MainFragment(), "main");
ft.Commit();
}
public void NavigateToTipCalc()
{
_tipCalc = _tipCalc ?? new TipCalcPage().CreateSupportFragment(this);
var ft = SupportFragmentManager.BeginTransaction();
ft.AddToBackStack(null);
ft.Replace(Resource.Id.fragment_frame_layout, _tipCalc, "TipCalc");
ft.Commit();
}
}
}