LayoutInflate: Avoid passing null as the view root

时间:2020-01-08 14:16:39   收藏:0   阅读:107

今天使用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)

 

原文:https://www.cnblogs.com/yongdaimi/p/12166138.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!