简体   繁体   English

Xamarin Native 到 Forms 的转换

[英]Xamarin Native to Forms transition

I am working with the Xamarin forms app that uses native camera.我正在使用使用本机相机的 Xamarin 表单应用程序。 I am trying to switch from Forms to Native and then back to forms based on https://github.com/supreettare/Forms2Native2Forms/blob/master/FormsBasics.Android/FormsActivity.cs我正在尝试从表单切换到本机,然后再切换回基于https://github.com/supreettare/Forms2Native2Forms/blob/master/FormsBasics.Android/FormsActivity.cs 的表单

in Android: SetPage (App.GetSecondPage ());在Android中:SetPage(App.GetSecondPage());

in Forms:在表格中:

public static Page GetSecondPage ()
    {
        var formsPage = new NavigationPage (new MyThirdPage ()); 

        return formsPage;
    }

My concern is when I call this function it gives me android.view.InflateException: Binary XML file line #1: Error inflating class .我担心的是,当我调用这个函数时,它给了我android.view.InflateException: Binary XML file line #1: Error inflating class

If I do SetPage(new GetSecondPage()), I can navigate to the other page but then can not use Navigation.PushAsync() anywhere on that page.如果我执行 SetPage(new GetSecondPage()),我可以导航到另一个页面,但不能在该页面的任何地方使用 Navigation.PushAsync()

Have you tried to use Page.CreateSupportFragment method ?您是否尝试过使用Page.CreateSupportFragment方法?

In your activity,you could load the page which defined in your forms like在您的活动中,您可以加载在表单中定义的页面,例如

protected override void OnCreate(Bundle bundle)
{
    base.OnCreate(bundle);
    Forms.Init(this, bundle);
    SetContentView(Resource.Layout.Main);          
    Android.Support.V4.App.Fragment mainPage = YourPage.CreateSupportFragment(this);
    SupportFragmentManager
        .BeginTransaction()
        .Replace(Resource.Id.fragment_frame_layout, mainPage)
        .Commit();

}

you could refer to Nativie Forms你可以参考Nativie Forms

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM