Android fragment的写

c 复制代码
package com.zs.test_.fragment;
import java.util.HashMap;

public class MyFragment extends Fragment {
    TextView tv_id, tv_share_my, tv_gold;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_my, container, false);
        SharedPreferencesUtils sharedPreferencesUtils = SharedPreferencesUtils.getInstance(getActivity());
        about_my = view.findViewById(R.id.about_my);
        return view;
    }

    @Override
    public void onDetach() {
        super.onDetach();

        EventBus.unregister(this);
    }
}

1.继承于fragment

extends Fragment

2.将 XML 布局文件 (R.layout.fragment_no_fold_tab)解析为对应的 View 层次结构。

View view = inflater.inflate(R.layout.fragment_my, container, false);、

相关推荐
ritxgt0067 小时前
MySQL 数据增删改查
android·数据库·mysql
zlpzpl8 小时前
MySQL 的 INSERT(插入数据)详解
android·数据库·mysql
Jomurphys11 小时前
Compose 调用 - 震动 LocalHapticFeedback
android·compose
非凡ghost11 小时前
小X分身APP(手机分身类工具)
android·windows·学习·智能手机·软件需求
erqi14 小时前
Compose你入门吧
android
q***765614 小时前
MySQL 中如何进行 SQL 调优
android·sql·mysql
zhanglinping61914 小时前
MySQL——内置函数
android·数据库·mysql
m***787414 小时前
mysql之字符串函数
android·数据库·mysql
w***711015 小时前
MySQL 事务的操作和四大特性
android·数据库·mysql
松叶似针17 小时前
Flutter三方库适配OpenHarmony【secure_application】— Android 端 FLAG_SECURE 实现分析
android·flutter