“Avoid passing null as the view root” warning when inflating view for use by AlertDialog

前端 未结 10 731
面向向阳花
面向向阳花 2020-12-12 15:41

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

LayoutInfl         


        
10条回答
  •  Happy的楠姐
    2020-12-12 16:39

    From the documentation of View.inflate(), it says

    Inflate a view from an XML resource. This convenience method wraps the LayoutInflater class, which provides a full range of options for view inflation.

      @param context The Context object for your activity or application.
      @param resource The resource ID to inflate
      @param root A view group that will be the parent.  Used to properly inflate the  layout_* parameters.
    

提交回复
热议问题