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);、

相关推荐
Just_Paranoid11 分钟前
【TaskbarDelegate】屏蔽上滑返回桌面手势功能
android·systemui·navigation·launcher·gesture
赛恩斯17 分钟前
asfp 如何导入并使用aosp13
android
诸神黄昏EX28 分钟前
Android Safety 系列专题【篇三:Secure Boot机制】
android
李坤林1 小时前
Android Binder 详解(4) Binder 线程池
android·java·binder
PuddingSama2 小时前
Gson 很好,但在Kotlin上有更合适的序列化工具「Kotlin Serialization」
android·kotlin·gson
教程分享大师3 小时前
移动云电脑W132D安卓9当贝固件线刷机包_ROM刷机教程
android
程序之巅3 小时前
VS code 远程python代码debug
android·java·python
恋猫de小郭4 小时前
罗技鼠标因为服务器证书过期无法使用?我是如何解决 SSL 证书问题
android·前端·flutter
yongui478345 小时前
MATLAB中回归模型常用误差指标(MSE、RMSE、MAPE等)的实现方法
android·matlab·回归
莫比乌斯环5 小时前
【Android技能点】启动链路 + AMS/ATMS 基础概念掌握
android