小编Mar*_*nts的帖子

Curser适配器中的notifyDataSetChanged不使用listfragment

我有一个listfragment,显示数据库中的列表.除了一件我无法清理的小物品外,我还能正常工作.列表视图看起来像这样.

-----------------------------------------------------
text text text | some more text | delete row button |
-----------------------------------------------------
Run Code Online (Sandbox Code Playgroud)

我的问题:当用户按下删除行按钮行从数据库中删除,但不会从屏幕上,直到活动被停止并再次启动被删除.

我知道这notifyDataSetChanged()是更新这些列表的首选方法,但它似乎没有做任何事情......无论如何,下面是我notifyDataSetChanged()调用的游标适配器的代码.

public class CalcCursorAdapter extends SimpleCursorAdapter{

    private Context mContext;
    private ListView mListView;
    private int mLayout;
    private Cursor mcursor;

    protected static class ViewHolder {
        protected TextView text;
        protected ImageButton button;
        private int position;
      }


    @SuppressWarnings("deprecation")
    public CalcCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to) 
    {
        super(context, layout, c, from, to);
        this.mContext = context;
        this.mLayout = layout;
        this.mcursor = c; …
Run Code Online (Sandbox Code Playgroud)

android android-listfragment

5
推荐指数
1
解决办法
4667
查看次数

标签 统计

android ×1

android-listfragment ×1