Android How to - Request window feature








The following code shows how to Request window feature.

Example

Main layout xml file

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:text="Toggle Mode"
        android:onClick="onToggleClick" />
</RelativeLayout>

Main Activity Java code

import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.widget.TextView;
/*from   w  w w.j a  v a 2 s  .c  om*/
public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        requestWindowFeature(Window.FEATURE_LEFT_ICON);
//        requestWindowFeature(Window.FEATURE_RIGHT_ICON);
        requestWindowFeature(Window.FEATURE_PROGRESS);
        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        requestWindowFeature(Window.FEATURE_ACTION_BAR);
        
        setContentView(new TextView(this));
        
//        setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.ic_launcher);
//        setFeatureDrawableResource(Window.FEATURE_RIGHT_ICON, R.drawable.ic_launcher);
        setProgress(7500);
        setProgressBarIndeterminateVisibility(true);
        setProgressBarVisibility(true);
    }
}
null