Android LayoutInflater用法

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);

就不会出现问题了

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页