Detailed use of requestwindowfeature

Source: Internet
Author: User

Requestwindowfeature can be set with the following values:
// 1. default_features: default system status. Generally, this parameter 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

:
Default:

 
Progress:

No title:


 
Lefticon:


Fullscreen:

Indeterminate_progress:

 

Customtitle:


 

 

Code:
Package com. 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, this parameter 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
// ==================================== Feature_indeterminate_progress: uncertain progress
// Showfeature_indeterminate_progress ();
/// ==================================== Feature_custom_title
// Showfeature_custom_title ();
/// ============================== Feature_left_icon: icon on the left of the title bar
// Showfeature_left_icon ();
/// ==================================== Feature_no_title
// Showfeature_no_title ();
// ====================================== Feature_progress
Showfeature_progress ();

}

Private void showfeature_indeterminate_progress (){
Requestwindowfeature (window. feature_indeterminate_progress );
Setcontentview (R. layout. Main );
Getwindow (). setfeatureint (window. feature_indeterminate_progress, R. layout. Progress );
// It must be added. Otherwise, the display effect cannot be displayed. You can set the display or hide function later.
Setprogressbarindeterminatevisibility (true );
}

Private void showfeature_custom_title (){
// Customize the 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 );
// Add this sentence to hide title only when full screen is not added
Getwindow (). 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 in the title bar.
Setprogress (100 * MSG. What );
// Set a progress bar value next to the title bar
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.