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

前端 未结 7 730
旧时难觅i
旧时难觅i 2020-11-27 10:13

Passing null for root studio gives me this warning:

Avoid passing null as the view root (need to resolve layout parameters on the inflated layout\'s r

7条回答
  •  误落风尘
    2020-11-27 10:34

    Instead of doing

    convertView = infalInflater.inflate(R.layout.list_item, null);
    

    do

    convertView = infalInflater.inflate(R.layout.list_item, parent, false);
    

    It will inflate it with the given parent, but won't attach it to the parent.

提交回复
热议问题