android之针对fragment多次调用onCreateView的问题

来源:互联网 发布:2016年天猫双十一数据 编辑:程序博客网 时间:2024/06/04 18:07

android之针对fragment多次调用onCreateView的问题

直接上解决的代码模块

复制代码
private View rootView;@Override    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {        if (null != rootView) {            ViewGroup parent = (ViewGroup) rootView.getParent();            if (null != parent) {                parent.removeView(rootView);            }        } else {            rootView = inflater.inflate(layoutId, null);            initView(rootView);// 控件初始化        }        return rootView;    }
0 0
原创粉丝点击