方式一
LayoutInflater inflater1 = (LayoutInflater) getApplicationContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view1 = inflater1.inflate(R.layout.fragment_layout, null);
方式二
LayoutInflater inflater2 = LayoutInflater.from(getApplicationContext());
View view2 = inflater2.inflate(R.layout.fragment_layout, null);
连起来写
View view3 = LayoutInflater.from(getApplicationContext()).inflate(
R.layout.fragment_layout, null);
方式三
LayoutInflater inflater3 = getLayoutInflater();
View view4 = inflater2.inflate(R.layout.fragment_layout, null);