how to refresh the listView using the Cursor Adapter

前端 未结 6 2324
名媛妹妹
名媛妹妹 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:04

     btn_check.setOnClickListener( new OnClickListener() {
    
            @Override
            public void onClick(View view ) {
    
                String editTextValue = edit_check.getText().toString();
    
                if (editTextValue!=null) {
    
    
                    SQLDataSore sqlDataSore = new SQLDataSore(PrintContent.this);
    
                    Cursor cursor_update = sqlDataSore.updateData(editTextValue);
    
                     cursorDemo.swapCursor(cursor_update);
                     //or cursorDemo=new CursorDemo(this,cursor_update);
    
                      list_View.setAdapter(cursorDemo);
                }
    
            }
    

    Put this on the activity where declare the ListView . Just create a new adapter and put it in new cursor then recreate it or swap the cursor. make sure your listview or adapter not constant.

提交回复
热议问题