AsyncLayoutInflater
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
网友评论