android-lisiview-adapter

来源:互联网 发布:check it out 编辑:程序博客网 时间:2024/06/05 01:02

1.在layout中创建ListView并声明ID

2.创建一个新的布局文件,用以承载ListView每一行(View)中的内容,并在里面添加控件

3.创建适配器Adapter 并继承BaseAdapter,重新父类中的方法。



public DetailAdapter(){



}




4.在getView()中绑定我们新创建的View布局文件中的控件。并且可以在里面设置View控件的中的属性内容。


View view = convertView;
if(view == null){
view = LayoutInflater.from(context).inflate(R.layout.detail_list, null);
}

在adapter中绑定View控件。


5.在Activity中调用Adapter的setAdapter方法    detailAdapter.setData(data);并将(data)数据传过来,先要实例化



6额外内容:在EditText输入数据传到ListView中:











0 0