美文网首页
AsyncLayoutInflater

AsyncLayoutInflater

作者: CentForever | 来源:发表于2021-01-01 22:35 被阅读0次
    if(!isAsyncOn) {
                    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    View view = inflater.inflate(R.layout.layout_dummy, null);
                    LinearLayout inflatedLayout = (LinearLayout) view.findViewById(R.id.layout_dummy);
                    parentLayout.addView(inflatedLayout);
                }else {
                    AsyncLayoutInflater asyncInflator = new AsyncLayoutInflater(this);
                    asyncInflator.inflate(R.layout.layout_dummy, null, new AsyncLayoutInflater.OnInflateFinishedListener() {
                        @Override
                        public void onInflateFinished(View view, int resid, ViewGroup parent) {
                            LinearLayout inflatedLayout = (LinearLayout) view.findViewById(R.id.layout_dummy);
                            parentLayout.addView(inflatedLayout);
                        }
                    });
                }
            }
    

    https://proandroiddev.com/asynclayoutinflater-on-the-way-to-the-ui-thread-to-be-responsive-743cb6cb201

    相关文章

      网友评论

          本文标题:AsyncLayoutInflater

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