LayoutInflater inflater =
LayoutInflater.from(this);
View v = inflater.inflate(R.layout.dialog1, null);
TextView tv = (TextView)v.findViewById(R.id.textView1);
使用该用法会导致提示:
Avoid passing null as the view root (needed to resolve layout parameters on the inflated layout's root element)
LayoutInflater inflater =
LayoutInflater.from(this);
View v = inflater.inflate(R.layout.dialog1, new LinearLayout(this),false);
TextView tv = (TextView)v.findViewById(R.id.textView1);
就不会出现问题了