首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用CursorAdapter

使用CursorAdapter
EN

Stack Overflow用户
提问于 2014-10-24 00:27:07
回答 1查看 43关注 0票数 0

这是我的游标适配器类。我将此适配器设置为listview。我也做了notifydatasethanged()。但是,我仍然没有得到任何结果,即当添加项时,列表视图仍然显示为空白。

代码语言:javascript
复制
public class tasksCursorAdapter extends CursorAdapter {
public tasksCursorAdapter(Context context, Cursor c, boolean autoRequery) {
    super(context, c, autoRequery);
}

@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {

    LayoutInflater inflater = LayoutInflater.from(parent.getContext());
    View retView = inflater.inflate(R.layout.single_row, parent, false);
    return retView;
}

@Override
public void bindView(View view, Context context, Cursor cursor) {

    TextView tvTask, tvDate, tvTime;
    tvTask = (TextView) view.findViewById(R.id.task_added);
    tvDate = (TextView) view.findViewById(R.id.date_added);
    tvTime = (TextView) view.findViewById(R.id.time_added);
    tvTask.setText(cursor.getString(1));
    tvDate.setText(cursor.getString(2));
    tvTime.setText(cursor.getString(3));

}
}
EN

回答 1

Stack Overflow用户

发布于 2014-10-24 01:46:28

除非添加getCount方法,否则将看不到添加到列表视图中的视图

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26532802

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档