LayoutInflater的获取方式

1.LayoutInflater是什么?

通俗而讲,就是将xml中定义的布局找出来。

2.获取LayoutInflater的三种方式

  1. LayoutInflater inflater = getLayoutInflater();  //调用Activity的getLayoutInflater()

  2. LayoutInflater localinflater =  (LayoutInflater)context.getSystemService

                                                 (Context.LAYOUT_INFLATER_SERVICE);

  3. LayoutInflater inflater = LayoutInflater.from(context);

 

其实,这三种方式本质是相同的,从源码中可以看出

posted @ 2016-03-01 15:05  技术丶从积累开始  阅读(161)  评论(0编辑  收藏  举报