先说一下oncreateview,也就是基本在新建的时候系统就帮建好了
再说一下初始化@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_personal, container, false); L.d("执行此方法onCreateView"); return view; }
再然后是onresume@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); initView(); initData(); }
我在这里面写的是登录后用户信息的回显,当然这个也是可以用作监控网络,还有就是这个方法打开这个fragment是会执行的。@Override public void onResume() { super.onResume(); if ((boolean) SP.get(getActivity(), SP.USER_DATA_LOGINED, false)) { personal_user_name.setText((String) SP.get(getActivity(), SP.USER_DATA_USERNAME, "")); SingleImageTaskUtil imageTask = new SingleImageTaskUtil(personal_user_icon); imageTask.execute((String) SP.get(getActivity(), SP.USER_DATA_USERICONURL, "")); personal_login_linearlayout.setVisibility(View.GONE); personal_exit.setVisibility(View.VISIBLE); personal_logined_linearlayout.setVisibility(View.VISIBLE); // Thread loadThread = new Thread(new LoadThread()); // loadThread.start(); Thread getbitmapThread = new Thread(new getBitmapThread()); getbitmapThread.start(); } }
还有是onstart,放网络监控