Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android xamarin从一个片段导航到另一个片段_Android_Fragment_Xamarin.android - Fatal编程技术网

Android xamarin从一个片段导航到另一个片段

Android xamarin从一个片段导航到另一个片段,android,fragment,xamarin.android,Android,Fragment,Xamarin.android,我试图通过单击原始片段中的按钮从一个片段导航到另一个片段。我怎么会有例外 问题在于,您在调用transaction.Replace()时传递了一个布局,而应该传递将片段插入布局的视图组的Id 因此,包含片段的活动的布局应该如下所示: <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"

我试图通过单击原始片段中的按钮从一个片段导航到另一个片段。我怎么会有例外


问题在于,您在调用transaction.Replace()时传递了一个布局,而应该传递将片段插入布局的视图组的Id

因此,包含片段的活动的布局应该如下所示:

  <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        <FrameLayout
            android:id="@+id/content_frame"
            android:layout_width="match_parent"
            android:layout_height="fill_parent" />
    </FrameLayout>
最后是片段事务代码:

var trans = new FragmentManager.BeginTransaction();
trans.Replace(Resource.Id.content_frame, new FragmentStockSearch(), "FragmentStockSearch");
trans.AddToBackStack(null);
trans.Commit();

问题是,您在调用transaction.Replace()时传递了一个布局,而应该传递将片段插入布局的视图组的Id

因此,包含片段的活动的布局应该如下所示:

  <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        <FrameLayout
            android:id="@+id/content_frame"
            android:layout_width="match_parent"
            android:layout_height="fill_parent" />
    </FrameLayout>
最后是片段事务代码:

var trans = new FragmentManager.BeginTransaction();
trans.Replace(Resource.Id.content_frame, new FragmentStockSearch(), "FragmentStockSearch");
trans.AddToBackStack(null);
trans.Commit();