private class MyAdapter extends BaseAdapter{
private List<Person> persons;
@Override
public int getCount() {
// TODO Auto-generated method stub
return persons.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return persons.get(position);
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
//把布局文件转换成view类型对象
View view=View.inflate(MainActivity.this, R.layout.search, null);
//获取布局文件里的控件
TextView tv=(TextView) view.findViewById(R.id.myTitle);
//为控件添加内容
return view;
}
}
自定义数据适配器
最新推荐文章于 2019-06-20 12:25:11 发布