English | Site Directory

Android - An Open Handset Alliance Project

android.view
public abstract class

android.view.Window

java.lang.Object
android.view.Window

Abstract base class for a top-level window look and behavior policy. An instance of this class should be used as the top-level view added to the window manager. It provides standard UI policies such as a background, title area, default key processing, etc.

The only existing implementation of this abstract class is android.policy.PhoneWindow, which you should instantiate when needing a Window. Eventually that class will be refactored and a factory method added for creating Window instances without knowing about a particular implementation.

Nested Classes
Window.Callback API from a Window back to its caller. 

Summary

Constants

      Value  
int  FEATURE_CONTEXT_MENU  Flag for the context menu.  0x00000006 
int  FEATURE_INDETERMINATE_PROGRESS  Flag for indeterminate progress   0x00000005 
int  FEATURE_LEFT_ICON  Flag for having an icon on the left side of the title bar   0x00000003 
int  FEATURE_NO_TITLE  Flag for the "no title" feature, turning off the title at the top of the screen.  0x00000001 
int  FEATURE_OPTIONS_PANEL  Flag for the "options panel" feature.  0x00000000 
int  FEATURE_PROGRESS  Flag for the progress indicator feature   0x00000002 
int  FEATURE_RIGHT_ICON  Flag for having an icon on the right side of the title bar   0x00000004 
int  ID_ANDROID_CONTENT  The ID that the main layout in the XML layout file should have.  17170515  0x01060053 
int  PROGRESS_END  Ending value for the (primary) progress   10000  0x00002710 
int  PROGRESS_INDETERMINATE_OFF  Flag for setting the progress bar's indeterminate mode off   -4  0xfffffffc 
int  PROGRESS_INDETERMINATE_ON  Flag for setting the progress bar's indeterminate mode on   -3  0xfffffffd 
int  PROGRESS_SECONDARY_END  Highest possible value for the secondary progress   30000  0x00007530 
int  PROGRESS_SECONDARY_START  Lowest possible value for the secondary progress   20000  0x00004e20 
int  PROGRESS_START  Starting value for the (primary) progress   0x00000000 
int  PROGRESS_VISIBILITY_OFF  Flag for setting the progress bar's visibility to GONE   -2  0xfffffffe 
int  PROGRESS_VISIBILITY_ON  Flag for setting the progress bar's visibility to VISIBLE   -1  0xffffffff 

Public Constructors

          Window(Context context)

Public Methods

abstract        void  addContentView(View view, LayoutParams params)
Add an additional content view to the screen.
abstract        void  closeAllPanels()
abstract        void  closePanel(int featureId)
abstract        Bitmap  dupWindowBitmap()
Return a copy of the bitmap holding the overall contents of the window.
        View  findViewById(int id)
Finds a view that was identified by the id attribute from the XML that was processed in onCreate(Bundle).
abstract        void  freeze(SparseArray icicles)
    final    LayoutParams  getAttributes()
Retrieve the current window attributes associated with this panel.
    final    Callback  getCallback()
Return the current Callback interface for this window.
    final    Window  getContainer()
Return the container for this Window.
    final    Context  getContext()
Return the Context this window policy is running in, for retrieving resources and other information.
abstract        View  getCurrentFocus()
Return the view in this Window that currently has focus, or null if there are none.
abstract        View  getDecorView()
        int  getStyle()
Retrieve the value of the current style resource for the window; returns 0 if none is set.
abstract        ViewInflate  getViewInflate()
Quick access to the ViewInflate instance that this Window retrieved from its Context.
        WindowManager  getWindowManager()
Return the window manager allowing this Window to display its own windows.
    final    boolean  isActive()
abstract        boolean  isFloating()
Return whether this window is being displayed with a floating style (based on the windowIsFloating attribute in the style/theme).
abstract        boolean  isShortcutKey(int keyCode, KeyEvent event)
Is a keypress one of the defined shortcut keys for this window.
    final    void  makeActive()
abstract        void  openPanel(int featureId, KeyEvent event)
abstract        View  peekDecorView()
abstract        boolean  performPanelIdentifierAction(int featureId, int id, int flags)
abstract        boolean  performPanelShortcut(int featureId, int keyCode, KeyEvent event, int flags)
        boolean  requestFeature(int featureId)
Enable extended screen features.
        void  setAttributes(LayoutParams a)
Specify custom window attributes.
abstract        void  setBackgroundDrawable(Drawable drawable)
Change the background of this window to a custom Drawable.
        void  setBackgroundDrawableResource(int resid)
Change the background of this window to a Drawable resource.
        void  setCallback(Callback callback)
Set the Callback interface for this window, used to intercept key events and other dynamic operations in the window.
abstract        void  setChildDrawable(int featureId, Drawable drawable)
abstract        void  setChildInt(int featureId, int value)
        void  setContainer(Window container)
Set the container for this window.
abstract        void  setContentView(View view, LayoutParams params)
Set the screen content to an explicit view.
abstract        void  setContentView(View view)
Set the screen content to an explicit view.
abstract        void  setContentView(int layoutResID)
Set the screen content from a layout resource.
abstract        void  setFeatureDrawable(int featureId, Drawable drawable)
Set an explicit Drawable value for feature of this window.
abstract        void  setFeatureDrawableAlpha(int featureId, int alpha)
Set a custom alpha value for the given drawale feature, controlling how much the background is visible through it.
abstract        void  setFeatureDrawableResource(int featureId, int resId)
Set the value for a drawable feature of this window, from a resource identifier.
abstract        void  setFeatureDrawableUri(int featureId, Uri uri)
Set the value for a drawable feature of this window, from a URI.
abstract        void  setFeatureInt(int featureId, int value)
Set the integer value for a feature.
        void  setFlags(int flags, int mask)
Set the flags of the window, as per the WindowManager.LayoutParams flags.
        void  setFormat(int format)
Set the format of window, as per the PixelFormat types.
        void  setGravity(int gravity)
Set the gravity of the window, as per the Gravity constants.
        void  setLayout(int width, int height)
Set the width and height layout parameters of the window.
        void  setStyle(int styleResource)
Set a style resource for this window.
abstract        void  setTitle(CharSequence title)
abstract        void  setTitleColor(int textColor)
        void  setType(int type)
Set the type of the window, as per the WindowManager.LayoutParams types.
        void  setWindowManager(WindowManager wm, IBinder appToken, String appName)
Set the window manager for use by this Window to, for example, display panels.
abstract        boolean  superDispatchKeyEvent(KeyEvent event)
Used by custom windows, such as Dialog, to pass the key press event further down the view hierarchy.
abstract        boolean  superDispatchTouchEvent(MotionEvent event)
Used by custom windows, such as Dialog, to pass the touch screen event further down the view hierarchy.
abstract        boolean  superDispatchTrackballEvent(MotionEvent event)
Used by custom windows, such as Dialog, to pass the trackball event further down the view hierarchy.
abstract        void  takeKeyEvents(boolean get)
Request that key events come to this activity.
abstract        void  thaw(SparseArray icicles)
abstract        void  togglePanel(int featureId, KeyEvent event)

Protected Methods

    final    int  getFeatures()
Return the feature bits that are enabled.
    final    int  getLocalFeatures()
Return the feature bits that are being implemented by this Window.
abstract        void  onActive()
        void  setDefaultWindowFormat(int format)
Set the default format of window, as per the PixelFormat types.
Methods inherited from class java.lang.Object

Details

Constants

public static final int FEATURE_CONTEXT_MENU

Flag for the context menu. This is enabled by default.
Constant Value: 6 (0x00000006)

public static final int FEATURE_INDETERMINATE_PROGRESS

Flag for indeterminate progress
Constant Value: 5 (0x00000005)

public static final int FEATURE_LEFT_ICON

Flag for having an icon on the left side of the title bar
Constant Value: 3 (0x00000003)

public static final int FEATURE_NO_TITLE

Flag for the "no title" feature, turning off the title at the top of the screen.
Constant Value: 1 (0x00000001)

public static final int FEATURE_OPTIONS_PANEL

Flag for the "options panel" feature. This is enabled by default.
Constant Value: 0 (0x00000000)

public static final int FEATURE_PROGRESS

Flag for the progress indicator feature
Constant Value: 2 (0x00000002)

public static final int FEATURE_RIGHT_ICON

Flag for having an icon on the right side of the title bar
Constant Value: 4 (0x00000004)

public static final int ID_ANDROID_CONTENT

The ID that the main layout in the XML layout file should have.
Constant Value: 17170515 (0x01060053)

public static final int PROGRESS_END

Ending value for the (primary) progress
Constant Value: 10000 (0x00002710)

public static final int PROGRESS_INDETERMINATE_OFF

Flag for setting the progress bar's indeterminate mode off
Constant Value: -4 (0xfffffffc)

public static final int PROGRESS_INDETERMINATE_ON

Flag for setting the progress bar's indeterminate mode on
Constant Value: -3 (0xfffffffd)

public static final int PROGRESS_SECONDARY_END

Highest possible value for the secondary progress
Constant Value: 30000 (0x00007530)

public static final int PROGRESS_SECONDARY_START

Lowest possible value for the secondary progress
Constant Value: 20000 (0x00004e20)

public static final int PROGRESS_START

Starting value for the (primary) progress
Constant Value: 0 (0x00000000)

public static final int PROGRESS_VISIBILITY_OFF

Flag for setting the progress bar's visibility to GONE
Constant Value: -2 (0xfffffffe)

public static final int PROGRESS_VISIBILITY_ON

Flag for setting the progress bar's visibility to VISIBLE
Constant Value: -1 (0xffffffff)

Public Constructors

public Window(Context context)

Public Methods

public abstract void addContentView(View view, LayoutParams params)

Add an additional content view to the screen. Added after any existing ones in the screen -- existing views are NOT removed.

Parameters

view The desired content to display.
params Layout parameters for the view.

public abstract void closeAllPanels()

public abstract void closePanel(int featureId)

public abstract Bitmap dupWindowBitmap()

Return a copy of the bitmap holding the overall contents of the window. If the window is not attached to the window manager or not visible visible, null is returned.

Returns

  • A new Bitmap object holding a copy of the window's current contents.

public View findViewById(int id)

Finds a view that was identified by the id attribute from the XML that was processed in onCreate(Bundle).

Returns

  • The view if found or null otherwise.

public abstract void freeze(SparseArray icicles)

public final LayoutParams getAttributes()

Retrieve the current window attributes associated with this panel.

Returns

  • WindowManager.LayoutParams Either the existing window attributes object, or a freshly created one if there is none.

public final Callback getCallback()

Return the current Callback interface for this window.

public final Window getContainer()

Return the container for this Window.

Returns

  • Window The containing window, or null if this is a top-level window.

public final Context getContext()

Return the Context this window policy is running in, for retrieving resources and other information.

Returns

  • Context The Context that was supplied to the constructor.

public abstract View getCurrentFocus()

Return the view in this Window that currently has focus, or null if there are none. Note that this does not look in any containing Window.

Returns

  • View The current View with focus or null.

public abstract View getDecorView()

public int getStyle()

Retrieve the value of the current style resource for the window; returns 0 if none is set.

Returns

  • int The resource identifier of the current style or 0 if none.

public abstract ViewInflate getViewInflate()

Quick access to the ViewInflate instance that this Window retrieved from its Context.

Returns

  • ViewInflate The shared ViewInflate.

public WindowManager getWindowManager()

Return the window manager allowing this Window to display its own windows.

Returns

  • WindowManager The ViewManager.

public final boolean isActive()

public abstract boolean isFloating()

Return whether this window is being displayed with a floating style (based on the windowIsFloating attribute in the style/theme).

Returns

  • Returns true if the window is configured to be displayed floating on top of whatever is behind it.

public abstract boolean isShortcutKey(int keyCode, KeyEvent event)

Is a keypress one of the defined shortcut keys for this window.

Parameters

keyCode the key code from KeyEvent to check.
event the KeyEvent to use to help check.

public final void makeActive()

public abstract void openPanel(int featureId, KeyEvent event)

public abstract View peekDecorView()

public abstract boolean performPanelIdentifierAction(int featureId, int id, int flags)

public abstract boolean performPanelShortcut(int featureId, int keyCode, KeyEvent event, int flags)

public boolean requestFeature(int featureId)

Enable extended screen features. This must be called before setContentView(). May be called as many times as desired as long as it is before setContentView(). If not called, no extended features will be available. You can not turn off a feature once it is requested.

Parameters

featureId The desired features, defined as constants by Window.

Returns

  • The features that are now set.

public void setAttributes(LayoutParams a)

Specify custom window attributes.

Parameters

a The new window attributes, which will completely override any current values.

public abstract void setBackgroundDrawable(Drawable drawable)

Change the background of this window to a custom Drawable.

Parameters

drawable The new Drawable to use for this window's background.

public void setBackgroundDrawableResource(int resid)

Change the background of this window to a Drawable resource.

Parameters

resid The resource identifier of a drawable resource which will be installed as the new background.

public void setCallback(Callback callback)

Set the Callback interface for this window, used to intercept key events and other dynamic operations in the window.

Parameters

callback The desired Callback interface.

public abstract void setChildDrawable(int featureId, Drawable drawable)

public abstract void setChildInt(int featureId, int value)

public void setContainer(Window container)

Set the container for this window. If not set, the DecorWindow operates as a top-level window; otherwise, it negotiates with the container to display itself appropriately.

Parameters

container The desired containing Window.

public abstract void setContentView(View view, LayoutParams params)

Set the screen content to an explicit view. This view is placed directly into the screen's view hierarchy. It can itself be a complex view hierarhcy.

Parameters

view The desired content to display.
params Layout parameters for the view.

public abstract void setContentView(View view)

Set the screen content to an explicit view. This view is placed directly into the screen's view hierarchy. It can itself be a complex view hierarhcy.

Parameters

view The desired content to display.

public abstract void setContentView(int layoutResID)

Set the screen content from a layout resource. The resource will be inflated, adding all top-level views to the screen.

Parameters

layoutResID Resource ID to be inflated.

public abstract void setFeatureDrawable(int featureId, Drawable drawable)

Set an explicit Drawable value for feature of this window. You must have called requestFeature(featureId) before calling this function.

Parameters

featureId The desired drawable feature to change. Features are constants defined by Window.
drawable A Drawable object to display.

public abstract void setFeatureDrawableAlpha(int featureId, int alpha)

Set a custom alpha value for the given drawale feature, controlling how much the background is visible through it.

Parameters

featureId The desired drawable feature to change. Features are constants defined by Window.
alpha The alpha amount, 0 is completely transparent and 255 is completely opaque.

public abstract void setFeatureDrawableResource(int featureId, int resId)

Set the value for a drawable feature of this window, from a resource identifier. You must have called requestFeauture(featureId) before calling this function.

Parameters

featureId The desired drawable feature to change, defined as a constant by Window.
resId Resource identifier of the desired image.

See Also

public abstract void setFeatureDrawableUri(int featureId, Uri uri)

Set the value for a drawable feature of this window, from a URI. You must have called requestFeature(featureId) before calling this function.

The only URI currently supported is "content:", specifying an image in a content provider.

Parameters

featureId The desired drawable feature to change. Features are constants defined by Window.
uri The desired URI.

See Also

public abstract void setFeatureInt(int featureId, int value)

Set the integer value for a feature. The range of the value depends on the feature being set. For FEATURE_PROGRESSS, it should go from 0 to 10000. At 10000 the progress is complete and the indicator hidden.

Parameters

featureId The desired feature to change. Features are constants defined by Window.
value The value for the feature. The interpretation of this value is feature-specific.

public void setFlags(int flags, int mask)

Set the flags of the window, as per the WindowManager.LayoutParams flags.

Parameters

flags The new window flags (see WindowManager.LayoutParams).
mask Which of the window flag bits to modify.

public void setFormat(int format)

Set the format of window, as per the PixelFormat types. This overrides the default format that is selected by the Window based on its window decorations.

Parameters

format The new window format (see PixelFormat). Use PixelFormat.UNKNOWN to allow the Window to select the format.

See Also

public void setGravity(int gravity)

Set the gravity of the window, as per the Gravity constants. This controls how the window manager is positioned in the overall window; it is only useful when using WRAP_CONTENT for the layout width or height.

Parameters

gravity The desired gravity constant.

public void setLayout(int width, int height)

Set the width and height layout parameters of the window. The default for both of these is FILL_PARENT; you can change them to WRAP_CONTENT to make a window that is not full-screen.

Parameters

width The desired layout width of the window.
height The desired layout height of the window.

public void setStyle(int styleResource)

Set a style resource for this window. This can be used to override Screen attributes in the current theme.

Parameters

styleResource The name of a Screen style resource.

public abstract void setTitle(CharSequence title)

public abstract void setTitleColor(int textColor)

public void setType(int type)

Set the type of the window, as per the WindowManager.LayoutParams types.

Parameters

type The new window type (see WindowManager.LayoutParams).

public void setWindowManager(WindowManager wm, IBinder appToken, String appName)

Set the window manager for use by this Window to, for example, display panels. This is not used for displaying the Window itself -- that must be done by the client.

Parameters

wm The ViewManager for adding new windows.

public abstract boolean superDispatchKeyEvent(KeyEvent event)

Used by custom windows, such as Dialog, to pass the key press event further down the view hierarchy. Application developers should not need to implement or call this.

public abstract boolean superDispatchTouchEvent(MotionEvent event)

Used by custom windows, such as Dialog, to pass the touch screen event further down the view hierarchy. Application developers should not need to implement or call this.

public abstract boolean superDispatchTrackballEvent(MotionEvent event)

Used by custom windows, such as Dialog, to pass the trackball event further down the view hierarchy. Application developers should not need to implement or call this.

public abstract void takeKeyEvents(boolean get)

Request that key events come to this activity. Use this if your activity has no views with focus, but the activity still wants a chance to process key events.

public abstract void thaw(SparseArray icicles)

public abstract void togglePanel(int featureId, KeyEvent event)

Protected Methods

protected final int getFeatures()

Return the feature bits that are enabled. This is the set of features that were given to requestFeature(), and are being handled by this Window itself or its container. That is, it is the set of requested features that you can actually use.

To do: add a public version of this API that allows you to check for features by their feature ID.

Returns

  • int The feature bits.

protected final int getLocalFeatures()

Return the feature bits that are being implemented by this Window. This is the set of features that were given to requestFeature(), and are being handled by only this Window itself, not by its containers.

Returns

  • int The feature bits.

protected abstract void onActive()

protected void setDefaultWindowFormat(int format)

Set the default format of window, as per the PixelFormat types. This is the format that will be used unless the client specifies in explicit format with setFormat();

Parameters

format The new window format (see PixelFormat).
Build m5-rc15g - 14 May 2008 12:50