随笔15

来源:互联网 发布:网络监控客户端软件 编辑:程序博客网 时间:2024/04/30 00:45
  • LayoutInflater 对于配置界面的xml 文件, 我们很多时候是 setContentView(R.layout.main); 这样用的! 如果我们想其他代码的方式加载 xml 文件, 怎么办呢? android.view.LayoutInflater 类就是一个加载配置xml 文件到内存的工具, "inflater" 个人理解是填充的意思.
  • 除了LayoutInflater 还有一个 android.view.MenuInflater , 这个很常见, 创建菜单的时候使用.

      貌似LayoutInflater 对象获取方式挺多的.

  1. LayoutInflater.from(Context context);
  2. Activity.getMenuInflater();
  3. (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

 

      这些是我暂时知道的! 后面会逐渐添加的.

 

原创粉丝点击