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

相关推荐
_李小白13 小时前
【Android FrameWork】延伸阅读:AMS 的 handleApplicationCrash
android·开发语言·python
_李小白13 小时前
【Android FrameWork】第四十九天:SystemUI
android
Mr -老鬼13 小时前
移动端跨平台适配技术框架:从发展到展望
android·ios·小程序·uni-app
城东米粉儿14 小时前
compose measurePoliy 笔记
android
城东米粉儿14 小时前
Compose 延迟列表
android
GoldenPlayer14 小时前
SOLID原则-Software Develop
android
GoldenPlayer14 小时前
Android文件管理系统
android
冬奇Lab14 小时前
【Kotlin系列02】变量与数据类型:从val/var到空安全的第一课
android·kotlin·编程语言
alonewolf_9914 小时前
深入理解MySQL事务与锁机制:从原理到实践
android·数据库·mysql