AsyncLayoutInflater
2021-01-01 本文已影响0人
CentForever
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);
}
});
}
}