我一直在开发Android应用程序,但我有一个问题-ListView使用SimpleCursorAdapter(此光标从SQLite db获取信息),但是如果我编辑数据库,则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/

10-13 03:41