Android LayoutInflater用法

来源:互联网 发布:js 字符串 match 编辑:程序博客网 时间:2024/06/05 08:55

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

就不会出现问题了

1 0
原创粉丝点击