<?xml version="1.0" encoding="utf-8"?>
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/left_fragment"
android:name="com.llg.play.LeftFragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
<!--name 显示指明要添加的碎片类名-->
<FrameLayout
android:id="@+id/right_layout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<fragment
android:id="@+id/right_fragment"
android:name="com.llg.play.RightFragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
</FrameLayout>
是 Fragmentlayout 里放了fragment 里的布局错误 ==
这是书上一个动态添加Fragment的例子
你这里面有什么内容啊,除了容器没有具体的视图组件
刚才不知道这个代码怎么显示不全
<?xml version="1.0" encoding="utf-8"?>
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent">
android:id="@+id/left_fragment"
android:name="com.llg.play.LeftFragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
<!--name 显示指明要添加的碎片类名-->
android:id="@+id/right_layout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
android:id="@+id/right_fragment"
android:name="com.llg.play.RightFragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
好吧 字数有限制我还是第一次使用这个问答
<?xml version="1.0" encoding="utf-8"?>
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent">
布局是linearLayout 里面有fragment 和Fragmentlayout Fragmentlayout 里放了fragment 我是加了FragmentLayout 才不显示的
<?xml version="1.0" encoding="utf-8"?>
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent">
android:id="@+id/left_fragment"
android:name="com.llg.play.LeftFragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
<!--name 显示指明要添加的碎片类名-->
<FrameLayout
android:id="@+id/right_layout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<fragment
android:id="@+id/right_fragment"
android:name="com.llg.play.RightFragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
</FrameLayout>
</LinearLayout>
偏偏屏蔽了linearlayout 有毒
这个布局应该没问题的 之前运行也没问题 是i加了FragmentLayout才不显示 不过我点击一个有添加Fragment功能的按钮 它是可以显示目标Fragment的