Inflater与findViewById()区别
2012-04-29 10:19
183 查看
/**
* Inflater英文意思是膨胀,在Android中应该是扩展的意思吧。 LayoutInflater的作用类似于
* findViewById(),不同点是LayoutInflater是用来找layout文件夹下的xml布局文件,并且实例化! 而
* findViewById()是找具体某一个xml下的具体 widget控件(如:Button,TextView等)。
*/
// LayoutInflater的作用是,把一个View的对象与XML布局文件关联并实例化
LayoutInflater inflater = (LayoutInflater) listviewActivity.this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// LayoutInflater的作用是,把一个View的对象与XML布局文件关联并实例化
View itemView = inflater.inflate(R.layout.listview_item, null);
// View的对象实例化之后,可以通过findViewById()查找布局文件中的指定Id的组件
TextView title = (TextView) itemView.findViewById(R.id.txttitle);
TextView text = (TextView) itemView.findViewById(R.id.txtContent);
* Inflater英文意思是膨胀,在Android中应该是扩展的意思吧。 LayoutInflater的作用类似于
* findViewById(),不同点是LayoutInflater是用来找layout文件夹下的xml布局文件,并且实例化! 而
* findViewById()是找具体某一个xml下的具体 widget控件(如:Button,TextView等)。
*/
// LayoutInflater的作用是,把一个View的对象与XML布局文件关联并实例化
LayoutInflater inflater = (LayoutInflater) listviewActivity.this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// LayoutInflater的作用是,把一个View的对象与XML布局文件关联并实例化
View itemView = inflater.inflate(R.layout.listview_item, null);
// View的对象实例化之后,可以通过findViewById()查找布局文件中的指定Id的组件
TextView title = (TextView) itemView.findViewById(R.id.txttitle);
TextView text = (TextView) itemView.findViewById(R.id.txtContent);
相关文章推荐
- Inflater与findViewById()区别
- [Android]inflate方法与 findViewById 方法区别 | LayoutInflater的inflate函数用法详解
- ayoutInflater和findViewById() 的区别
- Android中setContentView、addContentView、inflate、LayoutInflater和findViewById()区别
- Inflater与findViewById()区别
- Inflater与findViewById()区别
- getLayoutInflater() 以及findViewById(R.id.outerlayout)区别
- Android] setContentView和inflater区别以及findViewById和inflater的区别
- Inflater与findViewById()区别
- [Android]inflate方法与 findViewById 方法区别 | LayoutInflater的inflate函数用法详解
- LayoutInflater和findViewById的区别
- Inflater与findViewById()区别
- [Android] setContentView和inflater区别以及findViewById和inflater的区别
- [Android]inflate方法与 findViewById 方法区别 | LayoutInflater的inflate函数用法详解
- LayoutInflater和findViewById() 的区别
- LayoutInflater和findViewById()
- LayoutInflater及findViewById使用
- Inflater—— LayoutInflater和findViewById()
- Android setContentView、LayoutInflater、findViewById
- findViewById在Activity和View中的区别