Search code examples
c#androidandroid-activityxamarinfragment

move from fragment to an activity in xamarin


I am working with xamarin andorid Application.In my application I have some fragments and activitis.How to move from aone fragment to an activity?I have tried StartActivity(typeof(TargetActivity)) but it says ,cannot implicitly convert type 'Type' to Intent. I also tried this

var intent = new Intent(this,typeof(TargetActivity));
StartActivity(intent);

but i got an erro :

Error CS1502: The best overloaded method match for 'Android.Content.Intent.Intent(Android.Content.Context, System.Type)' has some invalid arguments (CS1502) (AndroidApplication)

Error CS1503: Argument 1: cannot convert from 'AndroidApplication.DrawerMenuFragment' to 'Android.Content.Context' (CS1503) (AndroidApplication)

Solution

  • Is you do this from Fragment you have to use Activity instead of this as your first argument like so:

    var intent = new Intent(Activity,typeof(TargetActivity));
    StartActivity(intent);