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 );}});}}