02 December 2014

Layoutinflater 介绍

inflate的意思是”充气,使……膨胀”。LayoutInflater可以看作是给Layout填充东西的一个类。主要是用来加载res/layout/*.xml布局。

三种实例方式

1. LayoutInflater inflater = getLayoutInflater(); 

2. LayoutInflater localinflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

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

本质都是调用context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);



blog comments powered by Disqus