Android's lint does not warn if the wrong LayoutInflator.inflate method is used

时间:2017-07-10 15:19:59

标签: android user-interface lint

If you use: LayoutInflator.inflate(resource, parent) instead of LayoutInflator.inflate(resource, parent, false)

you will most likely run into problems at runtime.

I'd like to see a lint warning for this or understand why this may not be a problem in all cases.

1 个答案:

答案 0 :(得分:1)

I'd like to see a lint warning for this

This is not an issue tracker.

why this may not be a problem in all cases

The two-parameter inflate() is fine if your objective is to add the inflated layout as a tree of children to the designated parent. In some cases, this is what you want. In other cases, it is not. I will readily agree that for most developers and most use cases, the three-parameter-with-false inflate() is the right answer (e.g., ListAdapter, RecyclerView.Adapter).