• 每日日报


    fragment入门
    通过xml文件声明fragment
    创建Fragment的布局文件 xml
    ①创建一个类继承Fragment
    ②重写onCreateView方法 把fragment对应的xml布局文件加载进来  在这个方法中创建fragment的界面
    1. public class FirstFragment extends Fragment {
    2. @Override
    3. public View onCreateView(LayoutInflater inflater, ViewGroup container,
    4. Bundle savedInstanceState) {
    5. //把fragment 对应的xml布局文件文件 转换为View对象 加载到界面上
    6. View view = inflater.inflate(R.layout.fragment_first, null);
    7. return view;
    8. }
    9. }
     
    ③ 在activity的布局文件中 声明一个fragment节点 ( fragment要小写  一定要声明一个id )
    1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    2. android:orientation="horizontal"
    3. android:layout_width="match_parent"
    4. android:layout_height="match_parent">
    5. <fragment android:name="com.itheima.fragmentdemo.FirstFragment"
    6. android:id="@+id/list"
    7. android:layout_weight="1"
    8. android:layout_width="0dp"
    9. android:layout_height="match_parent" />
    10. <fragment android:name="com.itheima.fragmentdemo.SecondFragment"
    11. android:id="@+id/viewer"
    12. android:layout_weight="2"
    13. android:layout_width="0dp"
    14. android:layout_height="match_parent" />
    15. </LinearLayout>
  • 相关阅读:
    概率派VS贝叶斯派
    Numpy-数组array操作
    Numpy基础
    PCA基本原理
    编程语言
    卷积神经网络基础
    IntelliJ IDEA Merge
    Mybatis 问题总结
    Lambda用法
    Map键值对取值, key是在"|"转义, value是在::取值
  • 原文地址:https://www.cnblogs.com/zhukaile/p/14836470.html
Copyright © 2020-2023  润新知