Android--requestwindowfeature

Source: Internet
Author: User

The values that requestwindowfeature can set are:
1.default_features: System default state, generally do not need to specify
2.feature_context_menu: Enable ContextMenu, which is enabled by default, generally does not need to specify
3.feature_custom_title: Custom caption. You must specify when you want to customize the caption. such as: When the caption is a button
4.feature_indeterminate_progress: Indeterminate Progress
5.feature_left_icon: Icon to the left of the title bar
6.feature_no_title: Untitled
7.feature_options_panel: Enable the Options Panel feature, which is enabled by default.
8.feature_progress: Progress indicator function
9.feature_right_icon: Icon to the right of the title bar

Example code:


public class Windowfeaturedemoactivity extends Activity {
@Override
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Value of Requestwindowfeature ();
1.default_features: System default state, generally do not need to specify
2.feature_context_menu: Enable ContextMenu, which is enabled by default, generally does not need to specify
3.feature_custom_title: Custom caption. You must specify when you want to customize the caption. such as: When the caption is a button
4.feature_indeterminate_progress: Indeterminate Progress
5.feature_left_icon: Icon to the left of the title bar
6.feature_no_title: Untitled
7.feature_options_panel: Enable the Options Panel feature, which is enabled by default.
8.feature_progress: Progress indicator function
9.feature_right_icon: Icon to the right of the title bar
========================feature_indeterminate_progress: Indeterminate Progress
Showfeature_indeterminate_progress ();
=====================feature_custom_title
Showfeature_custom_title ();
======================== Feature_left_icon: Icon to 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 has to be added otherwise the effect can be displayed or hidden in later settings
Setprogressbarindeterminatevisibility (TRUE);
}
private void Showfeature_custom_title () {
Custom caption. You must specify when you want to customize the caption. such as: When the caption 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);
Plus this sentence is set to full screen without adding only the title is hidden
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);
Changing the value of ProgressBar by thread
New Thread (New Runnable () {
public void Run () {
for (int i = 0; i < 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 progress value for a foreground in the title bar
Setprogress (Msg.what);
Set the progress value of a progress bar later in the title bar
Setsecondaryprogress (Msg.what + 10);
Super.handlemessage (msg);
}
};
}

Android--requestwindowfeature

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.