但我无法弄明白.如何使用Loader或changeCursor()来刷新我的ListVIEw
下面是我设置CursorAdapter的代码:
// SucessFully在这里完成
sqlDataSore datastore = new sqlDataSore(PrintContent.this);Cursor cursor = datastore.getJsONData();final CursorDemo cursorDemo = new CursorDemo(PrintContent.this,cursor);List_VIEw.setAdapter(cursorDemo);
我的按钮onClick我正在将值更新到数据库中
// SucessFully完成
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);//Here How Should I update my ListVIEw ...? } }
我的UpdateData方法:
public Cursor updateData(String editContent){ sqliteDatabase updateContent = getReadableDatabase(); Cursor cursor_update = updateContent.rawquery( "update " +table_name + " set content = '"+ editContent +"' "+" where _ID = 357",null); return cursor_update; }
CursorDemo类
public class CursorDemo extends CursorAdapter{ public CursorDemo(Context context,Cursor c) { super(context,c,false); // Todo auto-generated constructor stub } @OverrIDe public voID changeCursor(Cursor cursor) { // Todo auto-generated method stub super.changeCursor(cursor); } @OverrIDe public voID bindVIEw(VIEw vIEw,Context context,Cursor cursor) { // Todo auto-generated method stub TextVIEw txt_content = (TextVIEw) vIEw.findVIEwByID(R.ID.txt_content); TextVIEw txt_likes_count = (TextVIEw) vIEw.findVIEwByID(R.ID.txt_likescount); TextVIEw txt_name = (TextVIEw) vIEw.findVIEwByID(R.ID.txt_name); TextVIEw txt_display_name = (TextVIEw) vIEw.findVIEwByID(R.ID.txt_display_name); txt_content.setText(cursor.getString(cursor.getColumnIndex("content"))); } @OverrIDe public VIEw newVIEw(Context context,Cursor cursor,VIEwGroup vIEwGroup) { // Todo auto-generated method stub LayoutInflater inflater = LayoutInflater.from(context); VIEw vIEw = inflater.inflate(R.layout.message_row_vIEw,vIEwGroup,false); return vIEw; } }
任何帮助都得到赞赏……
});
这应该将旧光标换成新光标并重新加载数据.使用swapCursor时,旧游标未关闭.
总结以上是内存溢出为你收集整理的android – 如何使用Cursor Adapter刷新listView全部内容,希望文章能够帮你解决android – 如何使用Cursor Adapter刷新listView所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)