Progress Bar dialog box

Source: Internet
Author: User

1-Normal Progress dialog box
public void Bt_8 (View v)    {        final progressdialog progressdialog=new ProgressDialog (this);        Progressdialog.settitle ("hint");        Progressdialog.setmessage ("Please wait ...");        Progressdialog.setcancelable (false);//prevent clicking elsewhere to close        progressdialog.show ();        Do not write business code        //Open sub        -thread//multithreading-inherit; Implement Interface        //1-inherit Thread, override inside Method (run), call Start method        new Thread () {            @ Override public            Void Run () {                //delay  thread                try {                    thread.sleep (+);                }                catch (Exception e)                {                }                //Open Direct close                Progressdialog.dismiss ();            }        }. Start ();//responsible for starting a child thread, automatically executing the Run method     }
View Code

2-Horizontal Progress dialog box

Public void Bt_9 (View v) {final ProgressDialog progressdialog=new progressdialog (this);        Progressdialog.settitle ("Horizontal Progress dialog box");        Progressdialog.setmessage ("Loading ...");        Progressdialog.setcancelable (FALSE);        Set into horizontal Progressdialog.setprogressstyle (progressdialog.style_horizontal);        Progressdialog.show ();        Final TextView tv_1= (TextView) Findviewbyid (r.id.tv_1); The way to start a child thread implements an interface Runnable, there is only one method (run) New Thread (new Runnable () {@Override public void run () {//Simulation progress change for (int i=0;i<=100; i++)                    {progressdialog.setprogress (i);                    Deferred thread try {thread.sleep (500); } catch (Exception e) {}}//In the child thread to access the UI thread's view Runonuithr EAD (New Runnable () {@Override public void run () {Tv_1.sette                    XT ("Download Complete");                }                });            Turn the Progressdialog.dismiss directly off ();    }}). Start (); }
View Code

Progress Bar dialog box

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.