Android (Interface Programming # 5-progressdialog)

Source: Internet
Author: User
In Android, there is a progress bar corresponding to the progress bar in other languages, that is, the progressdialog we will mention, but it is absolutely beautiful and generous,
You can generate a progressdialog object, set the title (settitle) of the pop-up progress window, set the process message (setmessage), and then display (show). You can also directly call the showl static method of progressdialog, directly display a progress box. If you set progressdialog to be cancel, you can use the mobile phone rollback key to stop it. Otherwise, only Program Internal logic to abort, through the interface and Keyboard can not abort this progress box.
See Code :

Import Android. App. activity;
Import Android. App. progressdialog;
Import Android. OS. Bundle;
Import Android. View. Menu;
Import Android. View. menuitem;

Public class testprogress extends activity {

Private progressdialog progress = NULL;
@ Override
Public void oncreate (bundle savedinstancestate ){
Super. oncreate (savedinstancestate );
Setcontentview (R. layout. Main );
}

@ Override
Public Boolean oncreateoptionsmenu (menu ){
Super. oncreateoptionsmenu (menu );
Menu. Add (0, menu. First + 1, 1, "Open progress ");
Menu. Add (0, menu. First + 2, 2, "exit ");
Return true;
}

@ override
Public Boolean onoptionsitemselected (menuitem item) {
super. onoptionsitemselected (item);
switch (item. getitemid ()
{< br> case menu. first + 1:
{< br> progress = new progressdialog (this);
progress. settitle ("Progress !! ");
progress. setmessage ("Please wait for the operation... ");
progress. setcancelable (true);
progress. show ();
// progress = progressdialog. show (this, "progress! "," Please wait for operation... ");
break;
}< br> case menu. first + 2:
{< br> finish ();
break;
}< BR >}< br> return true;
}< BR >}

Related Article

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.