51 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			51 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			C#
		
	
	
	
|  | using Android.App; | |||
|  | using Android.OS; | |||
|  | using Android.Runtime; | |||
|  | using Android.Views; | |||
|  | using Android.Widget; | |||
|  | using AndroidX.AppCompat.App; | |||
|  | using Google.Android.Material.BottomNavigation; | |||
|  | 
 | |||
|  | namespace App1 | |||
|  | { | |||
|  |     [Activity(Label = "@string/app_name", Theme = "@style/AppTheme", MainLauncher = true)] | |||
|  |     public class MainActivity : AppCompatActivity, BottomNavigationView.IOnNavigationItemSelectedListener | |||
|  |     { | |||
|  |         TextView textMessage; | |||
|  | 
 | |||
|  |         protected override void OnCreate(Bundle savedInstanceState) | |||
|  |         { | |||
|  |             base.OnCreate(savedInstanceState); | |||
|  |             Xamarin.Essentials.Platform.Init(this, savedInstanceState); | |||
|  |             SetContentView(Resource.Layout.activity_main); | |||
|  | 
 | |||
|  |             textMessage = FindViewById<TextView>(Resource.Id.message); | |||
|  |             BottomNavigationView navigation = FindViewById<BottomNavigationView>(Resource.Id.navigation); | |||
|  |             navigation.SetOnNavigationItemSelectedListener(this); | |||
|  |         } | |||
|  |         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); | |||
|  |         } | |||
|  |         public bool OnNavigationItemSelected(IMenuItem item) | |||
|  |         { | |||
|  |             switch (item.ItemId) | |||
|  |             { | |||
|  |                 case Resource.Id.navigation_home: | |||
|  |                     textMessage.SetText(Resource.String.title_home); | |||
|  |                     return true; | |||
|  |                 case Resource.Id.navigation_dashboard: | |||
|  |                     textMessage.SetText(Resource.String.title_dashboard); | |||
|  |                     return true; | |||
|  |                 case Resource.Id.navigation_notifications: | |||
|  |                     textMessage.SetText(Resource.String.title_notifications); | |||
|  |                     return true; | |||
|  |             } | |||
|  |             return false; | |||
|  |         } | |||
|  |     } | |||
|  | } | |||
|  | 
 |