Android适配器之CursorAdapter
来源:互联网 发布:java对接微信公众平台 编辑:程序博客网 时间:2024/04/30 15:52
CursorAdapter
CursorAdapter
extends BaseAdapterimplements Filterable
Converts the cursor into a CharSequence.
Get a View
that displays in the drop down popup the data at the specified position in the data set.
Returns a filter that can be used to constrain data with a filtering pattern.
ContentObserver
on the cursor receives a change notification.实际开发中一般也是会自定义cursor适配器;下面看代码:
必须实现以下函数
abstract View newView(Context context, Cursor cursor, ViewGroup parent)
Makes a new view to hold the data pointed to by cursor.
abstract void bindView(View view, Context context, Cursor cursor)
Bind an existing view to the data pointed to by cursor
newView该函数第一次回调用后,如果数据增加后也会再调用,但是重绘是不会调用的。
数据增加后,回调用该函数来生成与新增数据相对应的view。
bindView函数第一次回调用后,如果数据更新也会再调用,但重绘会再次调用的。
数据更新:
adapter.changeCursor(cursor);
adapter.notifyDataSetChanged()
public class MyCurasorAdapter extends CursorAdapter {
private LayoutInflater layoutInflater;
private Context mContext;
public MyCurasorAdapter(Context context, Cursor c, int flags) {
super(context, c, flags);
this.mContext = context;
}
@Override
public View newView(Context arg0, Cursor arg1, ViewGroup arg2) {
View view = LayoutInflater.from(mContext).inflate(
R.layout.listview_item, null);
return view;
}
@Override
public void bindView(View convertView, Context arg1, Cursor arg2) {
// TextView title = (TextView) convertView.findViewById(R.id.title);
TextView soure = (TextView) convertView.findViewById(R.id.source);
TextView title = (TextView) convertView.findViewById(R.id.title);
TextView source = (TextView) convertView.findViewById(R.id.source);
TextView create_time = (TextView) convertView
.findViewById(R.id.create_time);
TextView nickname = (TextView) convertView.findViewById(R.id.nickname);
ImageView imageView = (ImageView) convertView
.findViewById(R.id.wap_thumb);
source.setText(" ");
title.setText(arg2.getString(arg2.getColumnIndex("title")));
create_time.setText(arg2.getString(arg2.getColumnIndex("create_time")));
nickname.setText(arg2.getString(arg2.getColumnIndex("nickname")));
if (arg2.getString(arg2.getColumnIndex("wap_thumb")).equals("")) {
} else {
ImageJudge imageJudge = new ImageJudge(imageView,
arg2.getString(arg2.getColumnIndex("wap_thumb")));
imageJudge.ImgaeDown();
}
}
}
- Android适配器之CursorAdapter
- android之ListView中使用的适配器CursorAdapter
- Android之CursorAdapter用法
- Android之CursorAdapter示例
- Android之CursorAdapter用法
- Android之CursorAdapter用法
- Android之CursorAdapter用法
- Android之CursorAdapter用法
- Android之CursorAdapter用法
- Android使用之CursorAdapter
- Android CursorAdapter
- Android开发之通过CursorAdapter读取数据(源代码分享)
- Android 使用自定义cursorAdapter
- 【android】使用CursorAdapter注意事项
- Android CursorAdapter的使用
- Android中的CursorAdapter
- Android适配器之-----SimpleExpandableListAdapter
- Android适配器之-----SimpleAdapter
- MFC 滚动条学习
- 【索引】Counting
- 【efm32】开发板 蓝牙测试
- 用IT技术玩金融系列文章
- Axis1.4生成和调用Webservice
- Android适配器之CursorAdapter
- 我的栈
- 单片机其实很简单--前言
- HDU 1003 Max Sum
- tomcat源码阅读-1
- win7系统下安装matlab并正确配置
- ESC键坏了,VIM代替键
- Dynamic collapsible动态加载collapsible
- 结构型模7:代理模式(Proxy Pattern)