Android study notes 32: title bar progress bar

Source: Internet
Author: User

When the program is performing a time-consuming operation, it can display a progress bar on the title bar to tell the user that the program is still running and there is no problem. Android provides us with this mechanism.

Key Methods: setprogressbarindeterminatevisibility and setprogressbarvisibility

Public class titleprogressbar extends activity {@ overridepublic void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); // set window features: Enable the progress bar requestwindowfeature (window. feature_indeterminate_progress); setcontentview (R. layout. main); button bn1 = (button) findviewbyid (R. id. bn01); button bn2 = (button) findviewbyid (R. id. bn02); bn1.setonclicklistener (New onclicklistener () {@ overridepublic v Oid onclick (View Source) {// displays a progress bar without progress. Setprogressbarindeterminatevisibility (true); // displays the progress bar with progress. Setprogressbarvisibility (true); // set the progress bar. setprogress (4500) ;}}); bn2.setonclicklistener (New onclicklistener () {@ overridepublic void onclick (View Source) {// hide the progress bar without progress. Setprogressbarindeterminatevisibility (false); // hide the progress bar with progress. Setprogressbarvisibility (false );}});}}

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.