【Android开发经验】LayoutInflater—— 你可能对它并不了解甚至错误使用
今天,看到了一篇文章讲LayoutInflater的使用方法。瞬间感觉自己对这个类确实不够了解,于是简单的看了下LayoutInflater类的源码。对这个类有了新的认识。 首先。LayoutInflater这个类是用来干嘛的呢? 我们最经常使用的便是LayoutInflater的inflate方法。这种方法重载了四种调用方式。分别为: 1.public View inflate(int resource, ViewGroup root) 2.public View inflate(int resource, ViewGroup root, boolean attachToRoot) 3.public View inflate(XmlPullParser parser, ViewGroup root) 4.public View inflate(XmlPullParser parser, ViewGroup root, boolean attachToRoot) 这四种使用方式中。我们最经常使用的是第一种方式。inflate方法的主要作用就是将xml转换成一个View对象。用于动态的创...