首页 > 其他 > 详细

LayoutInflate: Avoid passing null as the view root

时间:2020-01-08 14:16:39      阅读:107      评论:0      收藏:0      [点我收藏+]

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!