这是我的游标适配器类。我将此适配器设置为listview。我也做了notifydatasethanged()。但是,我仍然没有得到任何结果,即当添加项时,列表视图仍然显示为空白。
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));
}
}发布于 2014-10-24 01:46:28
除非添加getCount方法,否则将看不到添加到列表视图中的视图
https://stackoverflow.com/questions/26532802
复制相似问题