-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMainActivity.cs
81 lines (72 loc) · 2.72 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using Syncfusion.Maui.TabView;
using Android.App;
using Android.OS;
using Microsoft.Maui.Embedding;
using Syncfusion.Maui.Core.Hosting;
using Microsoft.Maui.Platform;
namespace NativeEmbeddingAndroid
{
[Activity(Label = "@string/app_name", MainLauncher = true)]
public class MainActivity : Activity
{
MauiContext? _mauiContext;
protected override void OnCreate(Bundle? savedInstanceState)
{
base.OnCreate(savedInstanceState);
MauiAppBuilder builder = MauiApp.CreateBuilder();
builder.UseMauiEmbedding<Microsoft.Maui.Controls.Application>();
builder.ConfigureSyncfusionCore();
MauiApp mauiApp = builder.Build();
_mauiContext = new MauiContext(mauiApp.Services, this);
SfTabView tabView = new SfTabView() { TabBarBackground=Colors.HotPink };
ListView listView = new ListView
{
RowHeight = 50,
ItemsSource = new string[] { "James", "Richard", "Clara", "Michael", "Alex", "Clara" },
ItemTemplate = new DataTemplate(() =>
{
var grid = new Grid
{
Margin = new Thickness(10, 5)
};
var label = new Label
{
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Start,
Margin = new Thickness(5, 0),
TextColor = Colors.Black,
FontSize = 16
};
label.SetBinding(Label.TextProperty, ".");
grid.Children.Add(label);
return new ViewCell { View = grid };
})
};
Grid favoritesGrid = new Grid { };
favoritesGrid.Children.Add(listView);
Grid recentsGrid = new Grid { BackgroundColor = Colors.Green };
Grid contactsGrid = new Grid { BackgroundColor = Colors.Blue };
var tabItems = new TabItemCollection
{
new SfTabItem()
{
Header = "FAVOURITES",
Content = favoritesGrid
},
new SfTabItem()
{
Header = "RECENTS",
Content = recentsGrid
},
new SfTabItem()
{
Header = "CONTACTS",
Content = contactsGrid
}
};
tabView.Items = tabItems;
Android.Views.View mauiView = tabView.ToPlatform(_mauiContext);
SetContentView(mauiView);
}
}
}