LayoutInflate: Avoid passing null as the view root

Posted yongdaimi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LayoutInflate: Avoid passing null as the view root相关的知识,希望对你有一定的参考价值。

今天使用LayoutInflate.inflate()方法加载一个布局,当参数root 为null 时,出现下列提示

Avoid passing null as the view root (needed to resolve layout parameters on the inflated layout‘s root element)

解决方案:

1. 添加:

@SuppressLint("InflateParams")

2. 修改成

view = View.inflate(context,R.layout.custom_layout,null);

改用View的inflate方法root为null就不会出现warning提示。

参考链接:
1. Avoid passing null as the view root (need to resolve layout parameters on the inflated layout‘s root element)

 

以上是关于LayoutInflate: Avoid passing null as the view root的主要内容,如果未能解决你的问题,请参考以下文章

[FAQ] web3js, Error: Please pass numbers as strings or BN objects to avoid precision errors.

Layoutinflate的inflate用法

Layoutinflate的inflate用法

Android layoutInflate.inflate 方法具体解释,removeView()错误解决

angr 01_angr_avoid avoid路径优化

angr 01_angr_avoid avoid路径优化