我是靠谱客的博主 兴奋中心,这篇文章主要介绍Fragment加入到Activity的两种方式(1)使用布局文件 <1>在Activity的布局文件中: (2)使用代码,现在分享给大家,希望可以做个参考。

(1)使用布局文件

<1>在Activity的布局文件中:


 <fragment
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:name="com.moliying.fragment.MenuFragment"
        android:id="@+id/menu_fragment"/>
    <fragment
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="3"
        android:name="com.moliying.fragment.ContentFragment"
        android:id="@+id/content_fragment"/>


        

<2>

创建MenuFragment类,继承Fragment

public class MenuFragment extends Fragment{
    @Override
    pub

最后

以上就是兴奋中心最近收集整理的关于Fragment加入到Activity的两种方式(1)使用布局文件 <1>在Activity的布局文件中: (2)使用代码的全部内容,更多相关Fragment加入到Activity的两种方式(1)使用布局文件内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(41)

评论列表共有 0 条评论

立即
投稿
返回
顶部