/*
*
* 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);