123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- using System;
- using Android.App;
- using Android.OS;
- using Android.Runtime;
- using Android.Views;
- using AndroidX.AppCompat.Widget;
- using AndroidX.AppCompat.App;
- using Google.Android.Material.FloatingActionButton;
- using Google.Android.Material.Snackbar;
- namespace App_demo
- {
- [Activity(Label = "@string/app_name", Theme = "@style/AppTheme.NoActionBar", MainLauncher = true)]
- public class MainActivity : AppCompatActivity
- {
- protected override void OnCreate(Bundle savedInstanceState)
- {
- base.OnCreate(savedInstanceState);
- Xamarin.Essentials.Platform.Init(this, savedInstanceState);
- SetContentView(Resource.Layout.activity_main);
- Toolbar toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
- SetSupportActionBar(toolbar);
- FloatingActionButton fab = FindViewById<FloatingActionButton>(Resource.Id.fab);
- fab.Click += FabOnClick;
- }
- public override bool OnCreateOptionsMenu(IMenu menu)
- {
- MenuInflater.Inflate(Resource.Menu.menu_main, menu);
- return true;
- }
- public override bool OnOptionsItemSelected(IMenuItem item)
- {
- int id = item.ItemId;
- if (id == Resource.Id.action_settings)
- {
- return true;
- }
- return base.OnOptionsItemSelected(item);
- }
- private void FabOnClick(object sender, EventArgs eventArgs)
- {
- View view = (View) sender;
- Snackbar.Make(view, "Replace with your own action", Snackbar.LengthLong)
- .SetAction("Action", (View.IOnClickListener)null).Show();
- }
- public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
- {
- Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
- base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
- }
- }
- }
|