如何刷新的ListView出的CursorAdapter的? [英] How to refresh the ListView out of the CursorAdapter?

查看:181
本文介绍了如何刷新的ListView出的CursorAdapter的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ListView在我的活动,这是在的onCreate 设置为

I've got a ListView in my Activity, which is set in the onCreate by

    MyCursorAdapter adapter = new TaskConditsCursorAdapter(this, conditsCursor, taskID, isNewTask);
    setListAdapter(adapter);

然后,我做了一些工作的 MyCursorAdapter 。除其他我有一个rowspecific AlertDialog:

Then I do some work in the MyCursorAdapter. Amongst others I have a rowspecific AlertDialog:

...
    builder.setPositiveButton("OK"), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int item) {
            changeTaskConditBoolValue(taskId, conditId, chosenBoolValue2);
            // refresh?
        }
    });

changeTaskConditBoolValue 我想重装我的名单,因为这种方法改变的东西在数据库中,但名单没有更新。 重新查询()的结果列表是空的。 我怎么能来上一级与适配器一次是我应该做的,然后它的工作?

After the changeTaskConditBoolValue I want to reload my List, since this method changed something in the database, but the List didn't update. requery() results in the list being empty. How can I come "one level above" to work with the adapter again and what should I do to it then?

非常感谢!

推荐答案

MyCursorAdapter 在所调用的的onClick方法 - 在我的情况下,它是 changeTaskConditBoolValue(...)我要呼吁:

In the MyCursorAdapter in the method called by the onClick - in my case it is changeTaskConditBoolValue(...) I have to call:

this.changeCursor(db.fetchAllTasks(myParameters));

这得到一个新的光标我的数据库级和替换自己的旧与新的。

This gets a new cursor by my Database-Class and replaces its own old one with the new one.

没有发现其他办法从CursorAdapter的内改变光标。

Found no other way to change the cursor from inside the CursorAdapter.

这篇关于如何刷新的ListView出的CursorAdapter的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆