美文网首页
Android 布局异步加载

Android 布局异步加载

作者: yunhen | 来源:发表于2024-01-29 16:07 被阅读0次

    先创建一个布局frag_setting_container,当作容器,里面带一个 圆形进度条, 异步加载结束的时候,向frag_setting_container 里面addView,在吧进度条隐藏掉,这样体验好一些

      if (rootView == null)
            rootView = inflater.inflate(R.layout.frag_setting_container,container,false);
        progressLayLoading = rootView.findViewById(R.id.progressLayLoading);
        AsyncLayoutInflater asyncLayInflater = new AsyncLayoutInflater(getActivity());
        asyncLayInflater.inflate(R.layout.fragment_setting, container, new AsyncLayoutInflater.OnInflateFinishedListener() {
                @Override
                public void onInflateFinished(@NonNull View view, int resid, @Nullable ViewGroup parent) {
                    if (rootView instanceof ViewGroup){
                        ((ViewGroup) rootView).addView(view);
                    }
                    if (progressLayLoading !=null)
                        progressLayLoading.setVisibility(View.GONE);
                    isViewLoaded = true;
         
                    if (isViewLoaded){
                        
                    }
    
    
                }
    });
    

    相关文章

      网友评论

          本文标题:Android 布局异步加载

          本文链接:https://www.haomeiwen.com/subject/obngodtx.html