2011-05-01 57 views
1

图片我在DB的图像,我把它放到我的GridView的这段代码:GridView控件与数据库

public void setNotes() 
    { 
     String[] columns = {NotesDbAdapt.KEY_ID, NotesDbAdapt.KEY_IMG, NotesDbAdapt.KEY_NAME, NotesDbAdapt.KEY_DATE, NotesDbAdapt.KEY_TIME}; 
     String table = NotesDbAdapt.NOTES_TABLE; 

     Cursor c = MainNote.mDB.getHandle().query(table, columns, null, null, null, null, null); 

     startManagingCursor(c); 

     SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, 
       R.layout.file_dialog_row, 
       c, 
       new String[] {NotesDbAdapt.KEY_IMG, NotesDbAdapt.KEY_NAME, NotesDbAdapt.KEY_DATE, NotesDbAdapt.KEY_TIME}, 
       new int[] {R.id.img, R.id.txt, R.id.date, R.id.time}); 

     adapter.setViewBinder(new NotesBinder()); 

     gridview.setAdapter(adapter); 
} 

一切ok,但却滚动很慢,生涩。似乎每次都从DB获取信息。如何解决它?

回答

1

此方法在API级别11中已弃用。请改用LoaderManager中的新CursorLoader类。它可以在后台线程上执行游标查询,以便它不会阻塞应用程序的用户界面。