android - Fill up table layout and show progress dialog -


i filling table layout via program. taking time. till whole tablelayout don't filled up, want show progress dialog.
cannot use new thread other uithread show progress dialog filling table layout.

how can show porgress dialog @ same time while filling table layout.

thanks.

here whole code

public class mainactivity extends activity {      private static textview edtsearch;     private progressdialog mprogressdialog;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);          final arraylist<string> lsmdlmaterial  = new arraylist<string>();         for(int i=0;i<1000;i++){             lsmdlmaterial.add("item:"+(i+1));         }         final textview txt= new textview(this);         final handler handler= new handler();         final handler handler1= new handler();         showprogressdialog();         new thread(new runnable() {              @override             public void run() {                     handler.post(new runnable() {                      @override                     public void run() {                         showcommodityselection(mainactivity.this,txt, lsmdlmaterial);                         dismissprogressdialog();                     }                 });               }         }).start();      }      private void showprogressdialog() {         mprogressdialog = new progressdialog(this);         mprogressdialog = progressdialog.show(                 this,                 "",                 "loading", true);     }      /**      * if progressdialog not null dismiss.      * **/     private void dismissprogressdialog() {         if (mprogressdialog != null) {             mprogressdialog.dismiss();             mprogressdialog = null;         }     }      // showcommodityselection selection using interface.     public static void showcommodityselection(final activity activity,              final textview txtmaterial,             final arraylist<string> lsmdlmaterial) {         /* click distributor view , open popup */          final dialog popupwindow = new dialog(activity);         popupwindow.requestwindowfeature(window.feature_no_title);         popupwindow.setcontentview(r.layout.xml_sc_selectdistributor);         popupwindow.getwindow().setsoftinputmode(                 windowmanager.layoutparams.soft_input_state_always_hidden);         popupwindow.setcanceledontouchoutside(false);         popupwindow.show();          final tablelayout sortbytableview = (tablelayout) popupwindow                 .findviewbyid(r.id.xml_sc_selectdistributor_tblview);         edtsearch = (edittext) popupwindow                 .findviewbyid(r.id.xml_salescontract_edtsearch);           /*edtsearch.addtextchangedlistener(new textwatcher() {              @override             public void ontextchanged(charsequence keyword, int start,                     int before, int count) {                 fillcommodity(popupwindow, activity,                         txtmaterial, lsmdlmaterial, sortbytableview,                         keyword.tostring());             }              @override             public void beforetextchanged(charsequence keyword, int start,                     int count, int after) {              }              @override             public void aftertextchanged(editable editable) {              }         });*/         fillcommodity(popupwindow, activity, txtmaterial,                 lsmdlmaterial, sortbytableview, "");      }      private static void fillcommodity(final dialog popupwindow,              final activity activity,             final textview txtmaterial,             final arraylist<string> lsmdlmaterial,             tablelayout sortbytableview, string keyword) {         sortbytableview.removeallviews();         (int = 0; < lsmdlmaterial.size(); i++) {             string codename = lsmdlmaterial.get(i)                     .tolowercase()                     ;             if (codename.contains(keyword)) {                 view viewline = new view(activity);                  viewline.setlayoutparams(new layoutparams(514, 1));                 final textview txt = new textview(activity);                 txt.setheight(40);                  txt.setpadding(10, 10, 10, 10);                 txt.settextsize(16);                 txt.setid(i);                 txt.settext(lsmdlmaterial.get(i));                 sortbytableview.addview(txt);                 sortbytableview.addview(viewline);                 txt.setonclicklistener(new view.onclicklistener() {                      @override                     public void onclick(view v) {                           popupwindow.dismiss();                      }                 });             }         }      }  } 


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -