gpt4 book ai didi

java - 如何编辑 SimpleCursorAdapter?

转载 作者:行者123 更新时间:2023-11-29 09:16:38 26 4
gpt4 key购买 nike

我一直在开发 Android 应用程序,我有一个问题 - ListView 使用 SimpleCursorAdapter(此游标从 SQLite 数据库获取信息),但如果我编辑我的数据库,ListView 将为空。我该如何解决?我希望在编辑 ListView 后刷新。我希望你可以帮助我。谢谢。

适配器:

    SimpleCursorAdapter adapter=new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, 
DictionaryDbWrapper.getInstance().getAllWords(), new String[]{DictionaryDbHelper.WORD, DictionaryDbHelper.CATEGORY},
new int[]{android.R.id.text1, android.R.id.text2});
mList.setAdapter(adapter);

更新代码:

    mDb.update(DictionaryDbHelper.TABLE_NAME, word, DictionaryDbHelper._ID+"=?", 
new String[]{String.valueOf(id)});

最佳答案

您可能需要在每次刷新后将 Adapter 分配给 ListView 吗?

关于java - 如何编辑 SimpleCursorAdapter?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9015395/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com