adapter模板
来源:互联网 发布:Sony编程 编辑:程序博客网 时间:2024/06/05 15:10
public abstract class MyBaseAdapter<T> extends BaseAdapter {
Context context;
List<T> datasource;
LayoutInflater inflater;
public MyBaseAdapter(Context context, List<T> datasource) {
super();
this.context = context;
this.datasource = datasource;
this.inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return datasource.size();
}
@Override
public T getItem(int position) {
// TODO Auto-generated method stub
return datasource.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
return getItemView(position, convertView, parent);
}
public abstract View getItemView(int position, View convertView,
ViewGroup parent);
public void addAll(List<T> list, Boolean flag) {
if (flag) {
datasource.clear();
}
datasource.addAll(list);
notifyDataSetChanged();
}
public void remov(T t) {
datasource.remove(t);
notifyDataSetChanged();
}
Context context;
List<T> datasource;
LayoutInflater inflater;
public MyBaseAdapter(Context context, List<T> datasource) {
super();
this.context = context;
this.datasource = datasource;
this.inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return datasource.size();
}
@Override
public T getItem(int position) {
// TODO Auto-generated method stub
return datasource.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
return getItemView(position, convertView, parent);
}
public abstract View getItemView(int position, View convertView,
ViewGroup parent);
public void addAll(List<T> list, Boolean flag) {
if (flag) {
datasource.clear();
}
datasource.addAll(list);
notifyDataSetChanged();
}
public void remov(T t) {
datasource.remove(t);
notifyDataSetChanged();
}
0 0
- adapter模板
- 编写自己的Adapter模板
- android--listView的adapter模板
- Android Adapter适配器模板(笔记)
- Android开发之ListView Adapter 模板
- Android 开发之 RecyclerView Adapter 模板
- Adapter
- adapter
- adapter
- adapter
- adapter
- Adapter
- Adapter
- adapter
- Adapter
- Adapter
- Adapter
- adapter
- 裂变位法加密 best coder
- Linux服务器利用Nethogs监控每个进程的网络使用情况
- Robot Framework自动化测试框架(二):WEB自动化
- Caffe学习3-使用预训练模型finetuning
- Spring源码解析—— ClassPathResource类
- adapter模板
- (礼拜一log)后台&前端联调:.tld应用
- cocoapods安装及使用(copy别人并加了自己的一些操作)
- VideoCore推流使用教程
- split 分割 字符串(分隔符如:* ^ : | , .) 及注意点
- 《移动端签到》——利用 JavaScript API实现定位
- ibatis和mybatis的区别
- 逆序对数(归并排序)
- 10大白帽黑客专用的 Linux 操作系统