Finally, when you set progressdialog. setprogressstyle (progressdialog. style_spinner), the effect is as follows:
When progressdialog. setprogressstyle (progressdialog. style_horizontal); is set, the effect is as follows:
Activity code example (the Code of the second image is used as an example)
Package cn.com. chenzheng_java; </P> <p> Import android. app. activity; <br/> Import android. app. progressdialog; <br/> Import android. content. dialoginterface; <br/> Import android. OS. bundle; <br/> Import android. view. view; <br/> Import android. widget. button; <br/> Import android. widget. toast; </P> <p>/** <br/> * @ description progressdialog test case <br/> * @ author chenzheng_java <br/> */ <br/> public class PR Ogressdialogactivity extends activity {<br/> @ override <br/> protected void oncreate (bundle savedinstancestate) {<br/> super. oncreate (savedinstancestate); <br/> setcontentview (R. layout. progressdialog); </P> <p> button = (button) findviewbyid (R. id. button_progress); <br/> button. setonclicklistener (new view. onclicklistener () {</P> <p> @ override <br/> Public void onclick (view v) {</P> <p> startdisplay (); </P> <p >}< br/>}); <br/>}</P> <p> private progressdialog progre; </P> <p>/** <br/> * display effect <br/> */<br/> private void startdisplay () {</P> <p> progressdialog = new progressdialog (this); <br/> progressdialog. settitle ("title"); <br/> progressdialog. seticon (R. drawable. excel); <br/> progressdialog. setindeterminate (false); // false indicates that the progress is displayed based on the Program progress. <br/> progressdialog. setprogressstyle (progressdialog. style_horizo Ntal); // set the progress bar shape <br/>/* set the progress bar image. This setting is valid for setprogressstyle (progressdialog. style_horizontal) and cannot be seen in this application! */<Br/> progressdialog. setprogressdrawable (getresources (). getdrawable (<br/> r. drawable. icon); <br/> progressdialog. setmessage ("message content"); <br/> progressdialog. setbutton ("cancel", new dialoginterface. onclicklistener () {<br/> @ override <br/> Public void onclick (dialoginterface dialog, int which) {<br/> toast. maketext (progressdialogactivity. this, "you have canceled the operation", <br/> toast. length_long ). show (); <br/> progressdialog. dismiss (); <br/>}< br/>}); <br/> progressdialog. show (); <br/> New thread () {<br/> Public void run () {</P> <p> try {<br/> sleep (3000); <br/>} catch (interruptedexception e) {<br/> E. printstacktrace (); <br/>}< br/> finally {<br/> // progressdialog. dismiss (); <br/>}</P> <p >}; </P> <p> }. start (); </P> <p >}< br/>
The Application of progressdialog is actually very simple. I will not talk about it here.
Note that progressdialog is actually inherited from alterdialog. Therefore, the usage of the two is similar to some extent.