android - Unable to load listview in asynctask from database -


i trying load items in listview queried db. ui blank 2 seconds , listviewis shown items. unable figure out wrong part in code. below code

protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_list_view);      // listview object xml     listview = (listview) findviewbyid(r.id.list);     dbhandler = new memodbhandler(this, null, null, 1);      listfetchasynctask asynclist = new listfetchasynctask();      asynclist.execute(); 

}

now asynctask load items

class listfetchasynctask extends asynctask<string, integer, list<memoinfo>> {      @override     protected void onpreexecute() {          listview.setfastscrollalwaysvisible(true);      }      protected list<memoinfo> doinbackground(string... params) {          cursor cursor = dbhandler.getfulllistcursor();         if (cursor != null) {              if(memolist != null)             {                 if(!memolist.isempty())                 {                     memolist.clear();                 }             }             else                 memolist = new  arraylist<memoinfo>();              if (cursor.movetofirst())             {                 {                      // version cursor                     string memotext = cursor.getstring(cursor.getcolumnindex("text"));                       string createddate = cursor.getstring(cursor.getcolumnindex("createddate"));                      integer id = cursor.getint(cursor.getcolumnindex("_id"));                      memoinfo memo = new memoinfo();                     memo.set_id(id);                     memo.set_memotext(memotext);                     memo.set_createddate(createddate);                     memolist.add(memo);                      // move next row                 } while (cursor.movetonext());             }         }          return memolist;      }      @override     protected void onpostexecute(list<memoinfo> list) {         adapter = new customadapter(getapplicationcontext(), list);         listview.setadapter(adapter);     } } 


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -