Disclaimer: I am a consultant at Amazon Web Services, and this is my personal blog. The opinions expressed here are solely mine and do not reflect the views of Amazon Web Services (AWS). Any statements made should not be considered official endorsements or statements by AWS.
You can use below code to open an activity from fragment in Xamarin Android.
Intent intent = new Intent(this.Activity, typeof(HomeDemo));
StartActivity(intent);
Here is the complete code:
public class HomeFragment : Fragment
{
public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
}
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
// Use this to return your custom view for this Fragment
View view = inflater.Inflate(Resource.Layout.HomeFragmentLayout, container, false);
Button btnHome = view.FindViewById<Button>(Resource.Id.btnHome);
btnHome.Click += BtnHome_Click;
return view;
}
private void BtnHome_Click(object sender, EventArgs e)
{
Intent intent = new Intent(this.Activity, typeof(HomeDemo));
StartActivity(intent);
}
}