吴劲韬

null

null

Android LayoutInflater布局填充器

Android LayoutInflater布局填充器

把一份xml布局文件转为View对象,这就是layoutinflater的作用。

  1. 对于一个没有被载入或者想要动态载入的界面,都需要使用LayoutInflater.inflate()来载入
  2. 对于一个已经载入的界面,就可以使用Activiyt.findViewById()方法来获得其中的界面元素
获得LayoutInflater的方式
  1. //加载布局管理器
  2. LayoutInflater inflater = LayoutInflater.from(context);
  3. //将xml布局转换为view对象
  4. convertView = inflater.inflate(R.layout.item_myseallist,parent, false);
  5. //利用view对象,找到布局中的组件
  6. convertView.findViewById(R.id.delete);// 删除
posted @ 2016-02-18 00:43  吴劲韬  阅读(584)  评论(0编辑  收藏  举报