how to refresh the listView using the Cursor Adapter

前端 未结 6 2246
名媛妹妹
名媛妹妹 2021-01-05 07:56

I have created a ListView using CursorAdapter . Now I am Trying to update the ListView and Refresh the value to the ListView .

6条回答
  •  心在旅途
    2021-01-05 08:29

    If you want to adapt/replace new cursor value to your list view , you should remove the old cursor from adapter and add new cursor value to the adapter.And finally adapt this adapter to listview using listview.setadapter(CursorAdapter) as follows. 
    
    liveTagListCursor = ctx.getContentResolver().query(
                            LiveTagProvider.TAG_LIST_URI, null, null, null, null);
    
        tagCursorAdapter = new LiveTagListCursorAdapter(getActivity(),
                            liveTagListCursor);
    
        tagCursorAdapter.swapCursor(liveTagListCursor);
    
        listview.setAdapter(tagCursorAdapter);
    

提交回复
热议问题