How to show a "Loading..." dialog in android? -
how create dialog show loading in android? want show dialog "loading..." while aynctask running. tried activity theme.dialog
. please help.
my code:
private class getlisttask extends asynctask<void, void, string> { @override protected string doinbackground(void... arg0) { sourceurl srcgrabber = new sourceurl (); string result = ""; try { url = url + usr + "&qry=" + query; result = srcgrabber.grabsource(url); } catch (exception e) { log.e("exception", e.tostring()); } return result; } @override protected void onpostexecute(string result) { textview txtview1 = (textview) findviewbyid(r.id.textview); txtview1.settext(result); } }
use progressdialog class show it.
/***************************************** * asynctask class parse , display ******************************************/ class asynctaskclassname extends asynctask<void,void, void>{ progressdialog progressdialog = null; /* *********************************** * pre-execute method * ********************************** */ @override protected void onpreexecute() { progressdialog = util.getprogressdialog(activityclassname.this, "please wait...", "parsing list... "); //activityclassname -> name of activity class want show progressdialog // progressdialog.hide(); progressdialog.show(); /* pre-execute configuration */ } /* *********************************** * execute method * ********************************** */ @override protected void doinbackground(void... arg0) { /* yourxec task ( load url) , return value */ return null; } /* *********************************** * post-execute method * ********************************** */ @override protected void onpostexecute(void result) { progressdialog.dismiss(); /* post -execute tasks */ }
Comments
Post a Comment