raghad abdulah

raghad abdulah

  • NA
  • 10
  • 2.3k

how can multi buttons open navigate pages for android app?

Mar 28 2018 3:32 AM
i craete an android application with four buttons in the first interface and i need each button to open another screen when clicked i did it correctly with the first button using this code 
  1. using Android.App;  
  2. using Android.Widget;  
  3. using Android.OS;  
  4.   
  5. namespace fitness_ghadi  
  6. {  
  7.     [Activity(Label = "fitness_ghadi", MainLauncher = true , Icon ="@drawable/icon")]  
  8.     public class MainActivity : Activity  
  9.     {  
  10.         protected override void OnCreate (Bundle bundle)  
  11.         {  
  12.             base.OnCreate(bundle);  
  13.             // Set our view from the "main" layout resource    
  14.             SetContentView(Resource.Layout.Main);  
  15.             Button button = FindViewById<Button>(Resource.Id.second);  
  16.             button.Click += delegate {  
  17.                 StartActivity(typeof(second));  
  18.             };  
  19.         }  
  20.          
  21.     }  
  22. }  
and this 
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Text;  
  5.   
  6. using Android.App;  
  7. using Android.Content;  
  8. using Android.OS;  
  9. using Android.Runtime;  
  10. using Android.Views;  
  11. using Android.Widget;  
  12.   
  13. namespace fitness_ghadi  
  14. {  
  15.     [Activity(Label = "second")]  
  16.     public class second : Activity  
  17.     {  
  18.         protected override void OnCreate(Bundle savedInstanceState)  
  19.         {  
  20.             base.OnCreate(savedInstanceState);  
  21.             SetContentView(Resource.Layout.Second);  
  22.             Button button = FindViewById<Button>(Resource.Id.First);  
  23.             button.Click += delegate {  
  24.                 StartActivity(typeof(MainActivity));  
  25.             };  
  26.             // Create your application here    
  27.         }  
  28.     }  
  29. }  
but when i try to make the same code for the rest buttons it did't work i found errors , how can i do it please?  

Answers (5)