[Solved] Android Warning: Avoid passing null as the view root

When making an application, the Android SDK is changed from 4.4 to 6.0. When using the inflate method of layoutinflater, the following situation appears

LayoutInflater.inflate(intresource,ViewGrouproot)

When the parameter root is null, a warning message appears

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

You should add:

@SuppressLint("InflateParams")

If you use the inflate method of view and root is null, the warning prompt will not appear

View.inflate(Contextcontext,intresource,ViewGrouproot)

 

Similar Posts: