java.lang.Object | |
↳ | android.widget.RemoteViews |
A class that describes a view hierarchy that can be displayed in another process. The hierarchy is inflated from a layout resource file, and this class provides some basic operations for modifying the content of the inflated hierarchy.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
RemoteViews.ActionException | Exception to send when something goes wrong executing an action | ||||||||||
RemoteViews.RemoteView | This annotation indicates that a subclass of View is alllowed to be used
with the RemoteViews mechanism. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
android.os.Parcelable
|
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
CREATOR | Parcelable.Creator that instantiates RemoteViews objects |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a new RemoteViews object that will display the views contained
in the specified layout file.
| |||||||||||
Create a new RemoteViews object that will inflate as the specified
landspace or portrait RemoteViews, depending on the current configuration.
| |||||||||||
Reads a RemoteViews object from a parcel.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Equivalent to calling
addView(View) after inflating the
given RemoteViews . | |||||||||||
Inflates the view hierarchy represented by this object and applies
all of the actions.
| |||||||||||
Creates and returns a copy of this
Object . | |||||||||||
Describe the kinds of special objects contained in this Parcelable's
marshalled representation.
| |||||||||||
Reutrns the layout id of the root layout associated with this RemoteViews.
| |||||||||||
Hook to allow clients of the LayoutInflater to restrict the set of Views
that are allowed to be inflated.
| |||||||||||
Applies all of the actions to the provided view.
| |||||||||||
Equivalent to calling
removeAllViews() . | |||||||||||
Call a method taking one Bitmap on a view in the layout for this RemoteViews.
| |||||||||||
Call a method taking one boolean on a view in the layout for this RemoteViews.
| |||||||||||
Call a method taking one Bundle on a view in the layout for this RemoteViews.
| |||||||||||
Call a method taking one byte on a view in the layout for this RemoteViews.
| |||||||||||
Call a method taking one char on a view in the layout for this RemoteViews.
| |||||||||||
Call a method taking one CharSequence on a view in the layout for this RemoteViews.
| |||||||||||
Equivalent to calling
Chronometer.setBase ,
Chronometer.setFormat ,
and Chronometer.start() or
Chronometer.stop() . | |||||||||||
Equivalent to calling View.setContentDescription(CharSequence).
| |||||||||||
Equivalent to calling
setDisplayedChild(int) | |||||||||||
Call a method taking one double on a view in the layout for this RemoteViews.
| |||||||||||
Equivalent to calling AdapterView.setEmptyView
| |||||||||||
Call a method taking one float on a view in the layout for this RemoteViews.
| |||||||||||
Equivalent to calling ImageView.setImageBitmap
| |||||||||||
Equivalent to calling ImageView.setImageResource
| |||||||||||
Equivalent to calling ImageView.setImageURI
| |||||||||||
Call a method taking one int on a view in the layout for this RemoteViews.
| |||||||||||
Call a method taking one Intent on a view in the layout for this RemoteViews.
| |||||||||||
Equivalent to calling View.setLabelFor(int).
| |||||||||||
Call a method taking one long on a view in the layout for this RemoteViews.
| |||||||||||
When using collections (eg.
| |||||||||||
Equivalent to calling
setOnClickListener(android.view.View.OnClickListener)
to launch the provided PendingIntent . | |||||||||||
When using collections (eg.
| |||||||||||
Equivalent to calling
ProgressBar.setMax ,
ProgressBar.setProgress , and
ProgressBar.setIndeterminate
If indeterminate is true, then the values for max and progress are ignored. | |||||||||||
Equivalent to calling
smoothScrollToPosition(int, int) . | |||||||||||
Equivalent to calling
setRemoteViewsAdapter(Intent) . | |||||||||||
This method was deprecated
in API level 14.
This method has been deprecated. See
setRemoteAdapter(int, Intent)
| |||||||||||
Equivalent to calling
smoothScrollToPosition(int, int) . | |||||||||||
Call a method taking one short on a view in the layout for this RemoteViews.
| |||||||||||
Call a method taking one String on a view in the layout for this RemoteViews.
| |||||||||||
Equivalent to calling
setTextColor(int) . | |||||||||||
Equivalent to calling
setCompoundDrawablesWithIntrinsicBounds(int, int, int, int) . | |||||||||||
Equivalent to calling
setCompoundDrawablesRelativeWithIntrinsicBounds(int, int, int, int) . | |||||||||||
Equivalent to calling TextView.setText
| |||||||||||
Equivalent to calling
setTextSize(int, float) | |||||||||||
Call a method taking one Uri on a view in the layout for this RemoteViews.
| |||||||||||
Equivalent to calling
setPadding(int, int, int, int) . | |||||||||||
Equivalent to calling View.setVisibility
| |||||||||||
Equivalent to calling
showNext() | |||||||||||
Equivalent to calling
showPrevious() | |||||||||||
Flatten this object in to a Parcel.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
android.os.Parcelable
| |||||||||||
From interface
android.view.LayoutInflater.Filter
|
Parcelable.Creator that instantiates RemoteViews objects
Create a new RemoteViews object that will display the views contained in the specified layout file.
packageName | Name of the package that contains the layout resource |
---|---|
layoutId | The id of the layout resource |
Create a new RemoteViews object that will inflate as the specified landspace or portrait RemoteViews, depending on the current configuration.
landscape | The RemoteViews to inflate in landscape configuration |
---|---|
portrait | The RemoteViews to inflate in portrait configuration |
Equivalent to calling addView(View)
after inflating the
given RemoteViews
. This allows users to build "nested"
RemoteViews
. In cases where consumers of RemoteViews
may
recycle layouts, use removeAllViews(int)
to clear any existing
children.
viewId | The id of the parent ViewGroup to add child into. |
---|---|
nestedView | RemoteViews that describes the child.
|
Inflates the view hierarchy represented by this object and applies all of the actions.
Caller beware: this may throw
context | Default context to use |
---|---|
parent | Parent that the resulting view hierarchy will be attached to. This method does not attach the hierarchy. The caller should do so when appropriate. |
Creates and returns a copy of this Object
. The default
implementation returns a so-called "shallow" copy: It creates a new
instance of the same class and then copies the field values (including
object references) from this instance to the new instance. A "deep" copy,
in contrast, would also recursively clone nested objects. A subclass that
needs to implement this kind of cloning should call super.clone()
to create the new instance and then create deep copies of the nested,
mutable objects.
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
Reutrns the layout id of the root layout associated with this RemoteViews. In the case that the RemoteViews has both a landscape and portrait root, this will return the layout id associated with the portrait layout.
Hook to allow clients of the LayoutInflater to restrict the set of Views that are allowed to be inflated.
clazz | The class object for the View that is about to be inflated |
---|
Applies all of the actions to the provided view.
Caller beware: this may throw
v | The view to apply the actions to. This should be the result of
the apply(Context, ViewGroup) call.
|
---|
Equivalent to calling removeAllViews()
.
viewId | The id of the parent ViewGroup to remove all
children from.
|
---|
Call a method taking one Bitmap on a view in the layout for this RemoteViews.
viewId | The id of the view on which to call the method. |
---|---|
methodName | The name of the method to call. |
value | The value to pass to the method. |
Call a method taking one boolean on a view in the layout for this RemoteViews.
viewId | The id of the view on which to call the method. |
---|---|
methodName | The name of the method to call. |
value | The value to pass to the method. |
Call a method taking one Bundle on a view in the layout for this RemoteViews.
viewId | The id of the view on which to call the method. |
---|---|
methodName | The name of the method to call. |
value | The value to pass to the method. |
Call a method taking one byte on a view in the layout for this RemoteViews.
viewId | The id of the view on which to call the method. |
---|---|
methodName | The name of the method to call. |
value | The value to pass to the method. |
Call a method taking one char on a view in the layout for this RemoteViews.
viewId | The id of the view on which to call the method. |
---|---|
methodName | The name of the method to call. |
value | The value to pass to the method. |
Call a method taking one CharSequence on a view in the layout for this RemoteViews.
viewId | The id of the view on which to call the method. |
---|---|
methodName | The name of the method to call. |
value | The value to pass to the method. |
Equivalent to calling Chronometer.setBase
,
Chronometer.setFormat
,
and Chronometer.start()
or
Chronometer.stop()
.
viewId | The id of the Chronometer to change |
---|---|
base | The time at which the timer would have read 0:00. This
time should be based off of
SystemClock.elapsedRealtime() . |
format | The Chronometer format string, or null to simply display the timer value. |
started | True if you want the clock to be started, false if not. |
Equivalent to calling View.setContentDescription(CharSequence).
viewId | The id of the view whose content description should change. |
---|---|
contentDescription | The new content description for the view. |
Equivalent to calling setDisplayedChild(int)
viewId | The id of the view on which to call
setDisplayedChild(int)
|
---|
Call a method taking one double on a view in the layout for this RemoteViews.
viewId | The id of the view on which to call the method. |
---|---|
methodName | The name of the method to call. |
value | The value to pass to the method. |
Equivalent to calling AdapterView.setEmptyView
viewId | The id of the view on which to set the empty view |
---|---|
emptyViewId | The view id of the empty view |
Call a method taking one float on a view in the layout for this RemoteViews.
viewId | The id of the view on which to call the method. |
---|---|
methodName | The name of the method to call. |
value | The value to pass to the method. |
Equivalent to calling ImageView.setImageBitmap
viewId | The id of the view whose bitmap should change |
---|---|
bitmap | The new Bitmap for the drawable |
Equivalent to calling ImageView.setImageResource
viewId | The id of the view whose drawable should change |
---|---|
srcId | The new resource id for the drawable |
Equivalent to calling ImageView.setImageURI
viewId | The id of the view whose drawable should change |
---|---|
uri | The Uri for the image |
Call a method taking one int on a view in the layout for this RemoteViews.
viewId | The id of the view on which to call the method. |
---|---|
methodName | The name of the method to call. |
value | The value to pass to the method. |
Call a method taking one Intent on a view in the layout for this RemoteViews.
viewId | The id of the view on which to call the method. |
---|---|
methodName | The name of the method to call. |
value | The Intent to pass the method.
|
Equivalent to calling View.setLabelFor(int).
viewId | The id of the view whose property to set. |
---|---|
labeledId | The id of a view for which this view serves as a label. |
Call a method taking one long on a view in the layout for this RemoteViews.
viewId | The id of the view on which to call the method. |
---|---|
methodName | The name of the method to call. |
value | The value to pass to the method. |
When using collections (eg. ListView
, StackView
etc.) in widgets, it is very
costly to set PendingIntents on the individual items, and is hence not permitted. Instead
a single PendingIntent template can be set on the collection, see setPendingIntentTemplate(int, PendingIntent)
, and the individual on-click
action of a given item can be distinguished by setting a fillInIntent on that item. The
fillInIntent is then combined with the PendingIntent template in order to determine the final
intent which will be executed when the item is clicked. This works as follows: any fields
which are left blank in the PendingIntent template, but are provided by the fillInIntent
will be overwritten, and the resulting PendingIntent will be used.
of the PendingIntent template will then be filled in with the associated fields that are
set in fillInIntent. See fillIn(Intent, int)
for more details.
viewId | The id of the view on which to set the fillInIntent |
---|---|
fillInIntent | The intent which will be combined with the parent's PendingIntent in order to determine the on-click behavior of the view specified by viewId |
Equivalent to calling
setOnClickListener(android.view.View.OnClickListener)
to launch the provided PendingIntent
.
When setting the on-click action of items within collections (eg. ListView
,
StackView
etc.), this method will not work. Instead, use {@link
RemoteViews#setPendingIntentTemplate(int, PendingIntent) in conjunction with
RemoteViews#setOnClickFillInIntent(int, Intent).
viewId | The id of the view that will trigger the PendingIntent when clicked |
---|---|
pendingIntent | The PendingIntent to send when user clicks
|
When using collections (eg. ListView
, StackView
etc.) in widgets, it is very
costly to set PendingIntents on the individual items, and is hence not permitted. Instead
this method should be used to set a single PendingIntent template on the collection, and
individual items can differentiate their on-click behavior using
setOnClickFillInIntent(int, Intent)
.
viewId | The id of the collection who's children will use this PendingIntent template when clicked |
---|---|
pendingIntentTemplate | The PendingIntent to be combined with extras specified
by a child of viewId and executed when that child is clicked
|
Equivalent to calling ProgressBar.setMax
,
ProgressBar.setProgress
, and
ProgressBar.setIndeterminate
If indeterminate is true, then the values for max and progress are ignored.
viewId | The id of the ProgressBar to change |
---|---|
max | The 100% value for the progress bar |
progress | The current value of the progress bar. |
indeterminate | True if the progress bar is indeterminate, false if not. |
Equivalent to calling smoothScrollToPosition(int, int)
.
viewId | The id of the view to change |
---|---|
offset | Scroll by this adapter position offset |
Equivalent to calling setRemoteViewsAdapter(Intent)
.
Can only be used for App Widgets.
viewId | The id of the AdapterView |
---|---|
intent | The intent of the service which will be providing data to the RemoteViewsAdapter |
This method was deprecated
in API level 14.
This method has been deprecated. See
setRemoteAdapter(int, Intent)
Equivalent to calling setRemoteViewsAdapter(Intent)
.
appWidgetId | The id of the app widget which contains the specified view. (This parameter is ignored in this deprecated method) |
---|---|
viewId | The id of the AdapterView |
intent | The intent of the service which will be providing data to the RemoteViewsAdapter |
Equivalent to calling smoothScrollToPosition(int, int)
.
viewId | The id of the view to change |
---|---|
position | Scroll to this adapter position |
Call a method taking one short on a view in the layout for this RemoteViews.
viewId | The id of the view on which to call the method. |
---|---|
methodName | The name of the method to call. |
value | The value to pass to the method. |
Call a method taking one String on a view in the layout for this RemoteViews.
viewId | The id of the view on which to call the method. |
---|---|
methodName | The name of the method to call. |
value | The value to pass to the method. |
Equivalent to calling setTextColor(int)
.
viewId | The id of the view whose text color should change |
---|---|
color | Sets the text color for all the states (normal, selected, focused) to be this color. |
Equivalent to calling
setCompoundDrawablesWithIntrinsicBounds(int, int, int, int)
.
viewId | The id of the view whose text should change |
---|---|
left | The id of a drawable to place to the left of the text, or 0 |
top | The id of a drawable to place above the text, or 0 |
right | The id of a drawable to place to the right of the text, or 0 |
bottom | The id of a drawable to place below the text, or 0 |
Equivalent to calling setCompoundDrawablesRelativeWithIntrinsicBounds(int, int, int, int)
.
viewId | The id of the view whose text should change |
---|---|
start | The id of a drawable to place before the text (relative to the layout direction), or 0 |
top | The id of a drawable to place above the text, or 0 |
end | The id of a drawable to place after the text, or 0 |
bottom | The id of a drawable to place below the text, or 0 |
Equivalent to calling TextView.setText
viewId | The id of the view whose text should change |
---|---|
text | The new text for the view |
Equivalent to calling setTextSize(int, float)
viewId | The id of the view whose text size should change |
---|---|
units | The units of size (e.g. COMPLEX_UNIT_SP) |
size | The size of the text |
Call a method taking one Uri on a view in the layout for this RemoteViews.
viewId | The id of the view on which to call the method. |
---|---|
methodName | The name of the method to call. |
value | The value to pass to the method. |
Equivalent to calling setPadding(int, int, int, int)
.
viewId | The id of the view to change |
---|---|
left | the left padding in pixels |
top | the top padding in pixels |
right | the right padding in pixels |
bottom | the bottom padding in pixels |
Equivalent to calling View.setVisibility
viewId | The id of the view whose visibility should change |
---|---|
visibility | The new visibility for the view |
Equivalent to calling showNext()
viewId | The id of the view on which to call showNext()
|
---|
Equivalent to calling showPrevious()
viewId | The id of the view on which to call showPrevious()
|
---|
Flatten this object in to a Parcel.
dest | The Parcel in which the object should be written. |
---|---|
flags | Additional flags about how the object should be written.
May be 0 or PARCELABLE_WRITE_RETURN_VALUE .
|