在xamarin MVVMCROSS中无法从android.support.v4.app.Fragment转换为android.app.Fragment

时间:2016-01-07 08:55:56

标签: android xamarin android-actionbar android-tabs

嘿在android(Xamarin)我试图在操作栏中添加标签,但我完成但是当我使用切换按钮时这个错误显示

' FragmentTransaction'是' Android.App.FragmentTransaction'之间的模糊参考。和' Android.Support.V4.App.FragmentTransaction'

这是我的代码

protected override void OnCreate(Bundle bundle)
    {

        DrawerLayout mDrawerLayout;

        base.OnCreate(bundle);

        // Set our view from the "main" layout resource
        SetContentView(Resource.Layout.Main);

        mDrawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);

        mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, Resource.Drawable.drawer, Resource.String.open_drawer, Resource.String.close_drawer); 


        FragmentTransaction transaction = FragmentManager.BeginTransaction();
        SlidingTabsFragment fragment = new SlidingTabsFragment();
        transaction.Replace(Resource.Id.sample_content_fragment, fragment);
        transaction.Commit();

        mDrawerLayout.SetDrawerListener(mDrawerToggle);
        ActionBar.SetDisplayHomeAsUpEnabled(true);
        ActionBar.SetHomeButtonEnabled(true);

    }

1 个答案:

答案 0 :(得分:1)

使用Android.App.FragmentTransaction transaction = FragmentManager.BeginTransaction();