To create an activity please follow the steps :
[Activity(Label = "MANDDO", MainLauncher = true)]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
}
}
Start an activity on button click :
[Activity(Label = "MANDDO", MainLauncher = true)]
public class MainActivity : Activity
{
Button btnclick;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
btnclick=FindViewById<Button>(Resource.Id.mybutton);
btnclick.Click+=delegate{
this.StartActivity(typeof(LoginSignUpActivity));
};
}
}
Where "LoginSignUpActivity" is the second activity that you want to open on button click.
- Start the visual studio and create the new project.
- Choose the android blank application from the project templates.
- By default the Xamarin.Android application creates an Activity called MainActivity.cs file the application
The MainActivity.cs contains the following code structure :
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
}
}
Start an activity on button click :
[Activity(Label = "MANDDO", MainLauncher = true)]
public class MainActivity : Activity
{
Button btnclick;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
btnclick=FindViewById<Button>(Resource.Id.mybutton);
btnclick.Click+=delegate{
this.StartActivity(typeof(LoginSignUpActivity));
};
}
}
Where "LoginSignUpActivity" is the second activity that you want to open on button click.

No comments:
Post a Comment