android - Show Progress Indicator before fill listview using CursorLoader -


what better way show progress indicator while listview not filled data of database?

i found examples of how this, using assynctask, in case, using loader /cursorloader.

public class testactivity extends sherlockfragmentactivity implements     loadercallbacks<cursor> {  simplecursoradapter madapter; listview mlistview;  private static final string[] ui_binding_from = new string[] {         testdbadapter.key_name, testdbadapter.key_icon };  private static final int[] ui_binding_to = new int[] { r.id.text, r.id.icon };  @override public void oncreate(bundle savedinstancestate) {      super.oncreate(savedinstancestate);      setcontentview(r.layout.activity_test);      mlistview = (listview) findviewbyid(r.id.listview);      madapter = new testadapter(getapplicationcontext(),             r.layout.list_item_test, null, ui_binding_from,             ui_binding_to, 0);      mlistview.setadapter(madapter);      getsupportloadermanager().initloader(0, null, this);  }  @override public loader<cursor> oncreateloader(int id, bundle args) {       uri uri = contentprovidertest.content_uri;      cursorloader cursorloader = new cursorloader(             this,              uri,             null,             null,             null,             null);      return cursorloader;  }  @override public void onloadfinished(loader<cursor> loader, cursor data) {     madapter.swapcursor(data); }  @override public void onloaderreset(loader<cursor> loader) {     madapter.swapcursor(null); } } 

a possible solution, create new class extending listfragment , use setlistshown() method , not know if best way solve issue.

thanks

add small progressbar layout file, visibility set "gone". before create cursorloader, set visibility "visible". appear. in onloadfinished, set progressbar visibility "gone". disappear, , listview load.

i'd use small style progressbar. learn more this, see reference docs android.widget.progressbar.

btw, visibility controlled view.setvisibility.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

node.js - Bad Request - node js ajax post -

uitableview - Create and use custom prototype table cells in xamarin ios using storyboard -