i check many pages ,want to find a way use fragment in a page,but find nothing, so i decide myself to resolved this problem,i use this way,this my renderer,
[assembly: ExportRenderer(typeof(Student.BaiduMapView), typeof(Student.BaiduMapViewRenderer))]
namespace Student
{
public class BaiduMapViewRenderer:ViewRenderer
{
public BaiduMapViewRenderer ()
{
}
protected override void OnElementChanged (ElementChangedEventArgs<View> e)
{
base.OnElementChanged (e);
Android.Views.LayoutInflater layoutInflater = Android.Views.LayoutInflater.FromContext(this.Context);
Android.Views.View view = layoutInflater.Inflate (Resource.Layout.chatlistfragment, null);
this.AddView (fr.View);
}
}
}
this is the layout chatlistfragment,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false" >
<fragment
android:id="@+id/fragment1"
android:name="student.TestFragment"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
but when i run,i meet a exception, Error inflating class fragment,if i remove fragment,the exception gone,i sure there have no error in the test fragment,because i have test it in a activity.
why ?i can't layoutInflater a layout containing a fragment?and how can i get a view of fragment and add to a page.