android之LayoutInflater讲解

在实际工作中,事先写好的布局文件往往不能满足我们的需求,有时会根据情况在代码中自定义控件,这就需要用到LayoutInflater-->用来获得布局文件对象的。

LayouInflater经常在BaseAdapter的getView()方法中用到,用来获取整个View并返回。

LayoutInflater有三种用法 :

(1)LayouInflater inflater = LayouInflater.from(this);

View layout = inflater.inflate(R.layout.main,null);

(2) LayoutInflater inflater  = getLayoutInflater();

View layout = inflater.inflate(R.layout.main,null);

(3) LayouInflater inflater = (LayouInflater)getSystemService(LAYOUT_INFLATER_SERVICE);

View layout = inflater.inflate(R.layout.main,null);

上一篇:NBU AIX ORACLE10G RAC恢复到AIX单实例(表空间恢复)


下一篇:详解一名合格PHP工程师应该具备的基本知识结构