Messy Android progressdialog Application

Source: Internet
Author: User

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.