Added in API level 16

MediaRouteButton


open class MediaRouteButton : View
kotlin.Any
   ↳ android.view.View
   ↳ android.app.MediaRouteButton

Summary

Inherited XML attributes
Inherited constants
Public constructors

MediaRouteButton(context: Context!, attrs: AttributeSet!)

MediaRouteButton(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

MediaRouteButton(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int)

Public methods
open Int

Gets the media route types for filtering the routes that the user can select using the media route chooser dialog.

open Unit

Call Drawable.jumpToCurrentState() on all Drawable objects associated with this view.

open Unit

This is called when the view is attached to a window.

open Unit

This is called when the view is detached from a window.

open Boolean

Call this view's OnClickListener, if it is defined.

open Unit
setContentDescription(contentDescription: CharSequence!)

Sets the View's content description.

open Unit

open Unit

Sets the types of routes that will be shown in the media route chooser dialog launched by this button.

open Unit
setVisibility(visibility: Int)

Set the visibility state of this view.

open Unit

Show the route chooser or controller dialog.

Protected methods
open Unit

This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

open IntArray!

Generate the new android.graphics.drawable.Drawable state for this view.

open Unit
onDraw(canvas: Canvas)

Implement this to do your drawing.

open Unit
onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int)

Measure the view and its content to determine the measured width and the measured height.

open Boolean

If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying.

Inherited functions
Inherited properties

Public constructors

MediaRouteButton

Added in API level 16
MediaRouteButton(context: Context!)

MediaRouteButton

Added in API level 16
MediaRouteButton(
    context: Context!,
    attrs: AttributeSet!)

MediaRouteButton

Added in API level 16
MediaRouteButton(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int)

MediaRouteButton

Added in API level 21
MediaRouteButton(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int,
    defStyleRes: Int)

Public methods

getRouteTypes

Added in API level 16
open fun getRouteTypes(): Int

Gets the media route types for filtering the routes that the user can select using the media route chooser dialog.

Return
Int The route types.

jumpDrawablesToCurrentState

Added in API level 16
open fun jumpDrawablesToCurrentState(): Unit

Call Drawable.jumpToCurrentState() on all Drawable objects associated with this view.

Also calls StateListAnimator.jumpToCurrentState() if there is a StateListAnimator attached to this view.
If you override this method you must call through to the superclass implementation.

onAttachedToWindow

Added in API level 16
open fun onAttachedToWindow(): Unit

This is called when the view is attached to a window. At this point it has a Surface and will start drawing. Note that this function is guaranteed to be called before onDraw(android.graphics.Canvas), however it may be called any time before the first onDraw -- including before or after onMeasure(int,int).
If you override this method you must call through to the superclass implementation.

onDetachedFromWindow

Added in API level 16
open fun onDetachedFromWindow(): Unit

This is called when the view is detached from a window. At this point it no longer has a surface for drawing.
If you override this method you must call through to the superclass implementation.

performClick

Added in API level 16
open fun performClick(): Boolean

Call this view's OnClickListener, if it is defined. Performs all normal actions associated with clicking: reporting accessibility event, playing a sound, etc.

Return
Boolean True there was an assigned OnClickListener that was called, false otherwise is returned.

setContentDescription

Added in API level 16
open fun setContentDescription(contentDescription: CharSequence!): Unit

Sets the View's content description.

A content description briefly describes the view and is primarily used for accessibility support to determine how a view should be presented to the user. In the case of a view with no textual representation, such as android.widget.ImageButton, a useful content description explains what the view does. For example, an image button with a phone icon that is used to place a call may use "Call" as its content description. An image of a floppy disk that is used to save a file may use "Save".

This should omit role or state. Role refers to the kind of user-interface element the View is, such as a Button or Checkbox. State refers to a frequently changing property of the View, such as an On/Off state of a button or the audio level of a volume slider.

Content description updates are not frequent, and are used when the semantic content - not the state - of the element changes. For example, a Play button might change to a Pause button during music playback.

Parameters
contentDescription CharSequence!: The content description.

setExtendedSettingsClickListener

Added in API level 16
open fun setExtendedSettingsClickListener(listener: View.OnClickListener!): Unit

setRouteTypes

Added in API level 16
open fun setRouteTypes(types: Int): Unit

Sets the types of routes that will be shown in the media route chooser dialog launched by this button.

Parameters
types Int: The route types to match.

setVisibility

Added in API level 16
open fun setVisibility(visibility: Int): Unit

Set the visibility state of this view.

Parameters
visibility Int: One of VISIBLE, INVISIBLE, or GONE.
Value is one of the following:

showDialog

Added in API level 16
open fun showDialog(): Unit

Show the route chooser or controller dialog.

If the default route is selected or if the currently selected route does not match the route types, then shows the route chooser dialog. Otherwise, shows the route controller dialog to offer the user a choice to disconnect from the route or perform other control actions such as setting the route's volume.

This will attach a DialogFragment to the containing Activity.

Protected methods

drawableStateChanged

Added in API level 16
protected open fun drawableStateChanged(): Unit

This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

If the View has a StateListAnimator, it will also be called to run necessary state change animations.

Be sure to call through to the superclass when overriding this function.
If you override this method you must call through to the superclass implementation.

onCreateDrawableState

Added in API level 16
protected open fun onCreateDrawableState(extraSpace: Int): IntArray!

Generate the new android.graphics.drawable.Drawable state for this view. This is called by the view system when the cached Drawable state is determined to be invalid. To retrieve the current state, you should use getDrawableState.

Parameters
extraSpace Int: if non-zero, this is the number of extra entries you would like in the returned array in which you can place your own states.
Return
IntArray! Returns an array holding the current Drawable state of the view.

onDraw

Added in API level 16
protected open fun onDraw(canvas: Canvas): Unit

Implement this to do your drawing.

Parameters
canvas Canvas: the canvas on which the background will be drawn.
This value cannot be null.

onMeasure

Added in API level 16
protected open fun onMeasure(
    widthMeasureSpec: Int,
    heightMeasureSpec: Int
): Unit

Measure the view and its content to determine the measured width and the measured height. This method is invoked by measure(int,int) and should be overridden by subclasses to provide accurate and efficient measurement of their contents.

CONTRACT: When overriding this method, you must call setMeasuredDimension(int,int) to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException, thrown by measure(int,int). Calling the superclass' onMeasure(int,int) is a valid use.

The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override onMeasure(int,int) to provide better measurements of their content.

If this method is overridden, it is the subclass's responsibility to make sure the measured height and width are at least the view's minimum height and width (getSuggestedMinimumHeight() and getSuggestedMinimumWidth()).

Parameters
widthMeasureSpec Int: horizontal space requirements as imposed by the parent. The requirements are encoded with android.view.View.MeasureSpec.
heightMeasureSpec Int: vertical space requirements as imposed by the parent. The requirements are encoded with android.view.View.MeasureSpec.

verifyDrawable

Added in API level 16
protected open fun verifyDrawable(who: Drawable): Boolean

If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying. This allows animations for those drawables to be scheduled.

Be sure to call through to the super class when overriding this function.
If you override this method you must call through to the superclass implementation.

Parameters
who Drawable: This value cannot be null.
Return
Boolean boolean If true then the Drawable is being displayed in the view; else false and it is not allowed to animate.