- LayoutInflater 对于配置界面的xml 文件, 我们很多时候是 setContentView(R.layout.main); 这样用的! 如果我们想其他代码的方式加载 xml 文件, 怎么办呢? android.view.LayoutInflater 类就是一个加载配置xml 文件到内存的工具, "inflater" 个人理解是填充的意思.
- 除了LayoutInflater 还有一个 android.view.MenuInflater , 这个很常见, 创建菜单的时候使用.
貌似LayoutInflater 对象获取方式挺多的.
- LayoutInflater.from(Context context);
- Activity.getMenuInflater();
- (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
这些是我暂时知道的! 后面会逐渐添加的.