"避免传递null作为视图根"通过AlertDialog充气视图以供使用时警告 [英] "Avoid passing null as the view root" warning when inflating view for use by AlertDialog

查看:183
本文介绍了"避免传递null作为视图根"通过AlertDialog充气视图以供使用时警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到的皮棉警告,避免传递null作为视图根膨胀与的意见时,如,如:

I get the lint warning, Avoid passing null as the view root when inflating views with null as parent, like:

LayoutInflater.from(context).inflate(R.layout.dialog_edit, null);

不过,鉴于被用作对内容的 AlertDialog ,使用的setView AlertDialog.Builder ,所以我不知道应该怎样传递的

However, the view is to be used as the content of an AlertDialog, using setView on AlertDialog.Builder, so I don't know what should be passed as the parent.

你觉得在应该是在这种情况下?

What do you think the parent should be in this case?

推荐答案

使用这种code膨胀对话视图没有警告:

Use this code to inflate the dialog view without a warning:

View.inflate(context, R.layout.dialog_edit, null);

这篇关于"避免传递null作为视图根"通过AlertDialog充气视图以供使用时警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆