Explanation of requestwindowfeature for Android

Source: Internet
Author: User

Requestwindowfeature can be set with the following values:
1. default_features: default system status, which is not required


2. feature_context_menu: Enable contextmenu. This option is enabled by default. Generally, you do not need to specify

3. feature_custom_title: Custom title. You must specify a custom title. For example, when the title is a button


4. feature_indeterminate_progress: uncertain progress


5. feature_left_icon: icon on the left of the title bar


6. feature_no_title: No title


7. feature_options_panel: enables the option panel function. It is enabled by default.

8. feature_progress: Progress indicator Function


9. feature_right_icon: icon on the right of the title bar

 

CodeAs follows:

Package Jason. my; import android. app. activity; import android. OS. bundle; import android. OS. handler; import android. OS. message; import android. view. window; import android. view. windowmanager; public class windowfeaturedemoactivity extends activity {@ override public void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); // value of requestwindowfeature (); // 1. default_features: default system status, generally not required Specify // 2. feature_context_menu: Enable contextmenu. This option is enabled by default. You do not need to specify // 3. feature_custom_title: Custom title. You must specify a custom title. For example, when the title is a button, // 4. feature_indeterminate_progress: uncertain progress // 5. feature_left_icon: icon on the left of the title bar // 6. feature_no_title: No title // 7. feature_options_panel: enables the option panel function. It is enabled by default. // 8. feature_progress: Progress indicator // 9. feature_right_icon: icon on the right of the title bar // response (); // showfeature_custom_title (); // response (); // showfeature_no_title (); showfeature_progress ();} private void response () {requestwindowfeature (window. feature_indeterminate_progress); setcontentview (R. layout. main); getwindow (). setfeatureint (window. feature_ I Ndeterminate_progress, R. layout. progress); // it must be added; otherwise, the display effect cannot be displayed. You can set to display or hide setprogressbarindeterminatevisibility (true);} private void showfeature_custom_title () {// custom title. You must specify a custom title. For example, when the title is a button, requestwindowfeature (window. feature_custom_title); setcontentview (R. layout. main); getwindow (). setfeatureint (window. feature_custom_title, R. layout. customtitle);} private void showfeature_left_icon () {requestwindowfeature (window. feature_left_icon); setcontentview (R. layout. main); getwindow (). setfeaturedrawableresource (window. feature_left_icon, R. drawable. icon);} private void showfeature_no_title () {requestwindowfeature (window. feature_no_title); setcontentview (R. layout. main); // if this sentence is set to full screen without adding, only the title getwindow () is hidden (). setflags (windowmanager. layoutparams. flag_fullscreen, windowmanager. layoutparams. flag_fullscreen);} private void showfeature_progress () {requestwindowfeature (window. feature_progress); setprogressbarvisibility (true); setcontentview (R. layout. main); settitle (""); getwindow (). setfeatureint (window. feature_progress, window. progress_visibility_on); // change the value of progressbar through a thread. New thread (New runnable () {public void run () {for (INT I = 0; I <10; I ++) {try {thread. sleep (1000); message m = new message (); M. what = (I + 1) * 20; windowfeaturedemoactivity. this. mymessagehandler. sendmessage (m);} catch (exception e) {e. printstacktrace ();}}}}). start ();} handler mymessagehandler = new handler () {// @ override public void handlemessage (Message MSG) {// set a progress bar value setprogress (100 * MSG. what); // set a progress bar value setsecondaryprogress (100 * MSG. what + 10); super. handlemessage (MSG );}};}

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.