public class RemoteViews extends Object implements Parcelable, LayoutInflater.Filter
Modifier and Type | Class and Description |
---|---|
static class |
RemoteViews.ActionException
Exception to send when something goes wrong executing an action
|
static class |
RemoteViews.OnClickHandler |
static interface |
RemoteViews.OnViewAppliedListener
Implement this interface to receive a callback when
applyAsync(android.content.Context, android.view.ViewGroup, java.util.concurrent.Executor, android.widget.RemoteViews.OnViewAppliedListener) or reapplyAsync(android.content.Context, android.view.View, java.util.concurrent.Executor, android.widget.RemoteViews.OnViewAppliedListener) is finished. |
static interface |
RemoteViews.RemoteView
This annotation indicates that a subclass of View is alllowed to be used
with the
RemoteViews mechanism. |
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static Parcelable.Creator<RemoteViews> |
CREATOR
Parcelable.Creator that instantiates RemoteViews objects
|
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Modifier | Constructor and Description |
---|---|
protected |
RemoteViews(ApplicationInfo application,
int layoutId)
Create a new RemoteViews object that will display the views contained
in the specified layout file.
|
|
RemoteViews(Parcel parcel)
Reads a RemoteViews object from a parcel.
|
|
RemoteViews(RemoteViews landscape,
RemoteViews portrait)
Create a new RemoteViews object that will inflate as the specified
landspace or portrait RemoteViews, depending on the current configuration.
|
|
RemoteViews(String packageName,
int layoutId)
Create a new RemoteViews object that will display the views contained
in the specified layout file.
|
|
RemoteViews(String packageName,
int userId,
int layoutId)
Create a new RemoteViews object that will display the views contained
in the specified layout file.
|
Modifier and Type | Method and Description |
---|---|
void |
addView(int viewId,
RemoteViews nestedView)
Equivalent to calling
ViewGroup.addView(View) after inflating the
given RemoteViews . |
View |
apply(Context context,
ViewGroup parent)
Inflates the view hierarchy represented by this object and applies
all of the actions.
|
View |
apply(Context context,
ViewGroup parent,
RemoteViews.OnClickHandler handler) |
CancellationSignal |
applyAsync(Context context,
ViewGroup parent,
Executor executor,
RemoteViews.OnViewAppliedListener listener)
Applies the views asynchronously, moving as much of the task on the background
thread as possible.
|
CancellationSignal |
applyAsync(Context context,
ViewGroup parent,
Executor executor,
RemoteViews.OnViewAppliedListener listener,
RemoteViews.OnClickHandler handler) |
RemoteViews |
clone()
Creates and returns a copy of this object.
|
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation.
|
int |
estimateMemoryUsage() |
int |
getLayoutId()
Returns the layout id of the root layout associated with this RemoteViews.
|
String |
getPackage() |
int |
getSequenceNumber()
Returns the number of actions in this RemoteViews.
|
void |
mergeRemoteViews(RemoteViews newRv)
Merges the passed RemoteViews actions with this RemoteViews actions according to
action-specific merge rules.
|
boolean |
onLoadClass(Class clazz)
Hook to allow clients of the LayoutInflater to restrict the set of Views
that are allowed to be inflated.
|
void |
reapply(Context context,
View v)
Applies all of the actions to the provided view.
|
void |
reapply(Context context,
View v,
RemoteViews.OnClickHandler handler) |
CancellationSignal |
reapplyAsync(Context context,
View v,
Executor executor,
RemoteViews.OnViewAppliedListener listener)
Applies all the actions to the provided view, moving as much of the task on the background
thread as possible.
|
CancellationSignal |
reapplyAsync(Context context,
View v,
Executor executor,
RemoteViews.OnViewAppliedListener listener,
RemoteViews.OnClickHandler handler) |
void |
removeAllViews(int viewId)
Equivalent to calling
ViewGroup.removeAllViews() . |
void |
setAccessibilityTraversalAfter(int viewId,
int nextId)
Equivalent to calling
View.setAccessibilityTraversalAfter(int) . |
void |
setAccessibilityTraversalBefore(int viewId,
int nextId)
Equivalent to calling
View.setAccessibilityTraversalBefore(int) . |
void |
setBitmap(int viewId,
String methodName,
Bitmap value)
Call a method taking one Bitmap on a view in the layout for this RemoteViews.
|
void |
setBoolean(int viewId,
String methodName,
boolean value)
Call a method taking one boolean on a view in the layout for this RemoteViews.
|
void |
setBundle(int viewId,
String methodName,
Bundle value)
Call a method taking one Bundle on a view in the layout for this RemoteViews.
|
void |
setByte(int viewId,
String methodName,
byte value)
Call a method taking one byte on a view in the layout for this RemoteViews.
|
void |
setChar(int viewId,
String methodName,
char value)
Call a method taking one char on a view in the layout for this RemoteViews.
|
void |
setCharSequence(int viewId,
String methodName,
CharSequence value)
Call a method taking one CharSequence on a view in the layout for this RemoteViews.
|
void |
setChronometer(int viewId,
long base,
String format,
boolean started)
Equivalent to calling
Chronometer.setBase ,
Chronometer.setFormat ,
and Chronometer.start() or
Chronometer.stop() . |
void |
setChronometerCountDown(int viewId,
boolean isCountDown)
Equivalent to calling
Chronometer.setCountDown on
the chronometer with the given viewId. |
void |
setContentDescription(int viewId,
CharSequence contentDescription)
Equivalent to calling View.setContentDescription(CharSequence).
|
void |
setDisplayedChild(int viewId,
int childIndex)
Equivalent to calling
AdapterViewAnimator.setDisplayedChild(int) |
void |
setDouble(int viewId,
String methodName,
double value)
Call a method taking one double on a view in the layout for this RemoteViews.
|
void |
setDrawableParameters(int viewId,
boolean targetBackground,
int alpha,
int colorFilter,
PorterDuff.Mode mode,
int level) |
void |
setEmptyView(int viewId,
int emptyViewId)
Equivalent to calling AdapterView.setEmptyView
|
void |
setFloat(int viewId,
String methodName,
float value)
Call a method taking one float on a view in the layout for this RemoteViews.
|
void |
setIcon(int viewId,
String methodName,
Icon value)
Call a method taking one Icon on a view in the layout for this RemoteViews.
|
void |
setImageViewBitmap(int viewId,
Bitmap bitmap)
Equivalent to calling ImageView.setImageBitmap
|
void |
setImageViewIcon(int viewId,
Icon icon)
Equivalent to calling ImageView.setImageIcon
|
void |
setImageViewResource(int viewId,
int srcId)
Equivalent to calling ImageView.setImageResource
|
void |
setImageViewUri(int viewId,
Uri uri)
Equivalent to calling ImageView.setImageURI
|
void |
setInt(int viewId,
String methodName,
int value)
Call a method taking one int on a view in the layout for this RemoteViews.
|
void |
setIntent(int viewId,
String methodName,
Intent value)
Call a method taking one Intent on a view in the layout for this RemoteViews.
|
void |
setLabelFor(int viewId,
int labeledId)
Equivalent to calling View.setLabelFor(int).
|
void |
setLong(int viewId,
String methodName,
long value)
Call a method taking one long on a view in the layout for this RemoteViews.
|
void |
setOnClickFillInIntent(int viewId,
Intent fillInIntent)
When using collections (eg.
|
void |
setOnClickPendingIntent(int viewId,
PendingIntent pendingIntent)
Equivalent to calling
View.setOnClickListener(android.view.View.OnClickListener)
to launch the provided PendingIntent . |
void |
setPendingIntentTemplate(int viewId,
PendingIntent pendingIntentTemplate)
When using collections (eg.
|
void |
setProgressBackgroundTintList(int viewId,
ColorStateList tint) |
void |
setProgressBar(int viewId,
int max,
int progress,
boolean indeterminate)
Equivalent to calling
ProgressBar.setMax ,
ProgressBar.setProgress , and
ProgressBar.setIndeterminate
If indeterminate is true, then the values for max and progress are ignored. |
void |
setProgressIndeterminateTintList(int viewId,
ColorStateList tint) |
void |
setProgressTintList(int viewId,
ColorStateList tint) |
void |
setRelativeScrollPosition(int viewId,
int offset)
Equivalent to calling
AbsListView.smoothScrollToPosition(int, int) . |
void |
setRemoteAdapter(int viewId,
ArrayList<RemoteViews> list,
int viewTypeCount)
Creates a simple Adapter for the viewId specified.
|
void |
setRemoteAdapter(int viewId,
Intent intent)
Equivalent to calling
AbsListView.setRemoteViewsAdapter(Intent) . |
void |
setRemoteAdapter(int appWidgetId,
int viewId,
Intent intent)
Deprecated.
This method has been deprecated. See
setRemoteAdapter(int, Intent) |
void |
setRemoteInputs(int viewId,
RemoteInput[] remoteInputs) |
void |
setScrollPosition(int viewId,
int position)
Equivalent to calling
AbsListView.smoothScrollToPosition(int, int) . |
void |
setShort(int viewId,
String methodName,
short value)
Call a method taking one short on a view in the layout for this RemoteViews.
|
void |
setString(int viewId,
String methodName,
String value)
Call a method taking one String on a view in the layout for this RemoteViews.
|
void |
setTextColor(int viewId,
ColorStateList colors) |
void |
setTextColor(int viewId,
int color)
Equivalent to calling
TextView.setTextColor(int) . |
void |
setTextViewCompoundDrawables(int viewId,
Icon left,
Icon top,
Icon right,
Icon bottom)
Equivalent to calling
TextView.setCompoundDrawablesWithIntrinsicBounds(Drawable, Drawable, Drawable, Drawable)
using the drawables yielded by Icon.loadDrawable(Context) . |
void |
setTextViewCompoundDrawables(int viewId,
int left,
int top,
int right,
int bottom)
Equivalent to calling
TextView.setCompoundDrawablesWithIntrinsicBounds(int, int, int, int) . |
void |
setTextViewCompoundDrawablesRelative(int viewId,
Icon start,
Icon top,
Icon end,
Icon bottom)
Equivalent to calling
TextView.setCompoundDrawablesRelativeWithIntrinsicBounds(Drawable, Drawable, Drawable, Drawable)
using the drawables yielded by Icon.loadDrawable(Context) . |
void |
setTextViewCompoundDrawablesRelative(int viewId,
int start,
int top,
int end,
int bottom)
Equivalent to calling
TextView.setCompoundDrawablesRelativeWithIntrinsicBounds(int, int, int, int) . |
void |
setTextViewCompoundDrawablesRelativeColorFilter(int viewId,
int index,
int color,
PorterDuff.Mode mode)
Equivalent to applying a color filter on one of the drawables in
TextView.getCompoundDrawablesRelative() . |
void |
setTextViewText(int viewId,
CharSequence text)
Equivalent to calling TextView.setText
|
void |
setTextViewTextSize(int viewId,
int units,
float size)
Equivalent to calling
TextView.setTextSize(int, float) |
void |
setUri(int viewId,
String methodName,
Uri value)
Call a method taking one Uri on a view in the layout for this RemoteViews.
|
void |
setViewLayoutMarginBottomDimen(int viewId,
int bottomMarginDimen)
Equivalent to setting
ViewGroup.MarginLayoutParams.bottomMargin . |
void |
setViewLayoutMarginEndDimen(int viewId,
int endMarginDimen) |
void |
setViewLayoutWidth(int viewId,
int layoutWidth)
Equivalent to setting
ViewGroup.LayoutParams.width . |
void |
setViewPadding(int viewId,
int left,
int top,
int right,
int bottom)
Equivalent to calling
View.setPadding(int, int, int, int) . |
void |
setViewVisibility(int viewId,
int visibility)
Equivalent to calling View.setVisibility
|
void |
showNext(int viewId)
Equivalent to calling
AdapterViewAnimator.showNext() |
void |
showPrevious(int viewId)
Equivalent to calling
AdapterViewAnimator.showPrevious() |
void |
writeToParcel(Parcel dest,
int flags)
Flatten this object in to a Parcel.
|
public static final Parcelable.Creator<RemoteViews> CREATOR
public RemoteViews(String packageName, int layoutId)
packageName
- Name of the package that contains the layout resourcelayoutId
- The id of the layout resourcepublic RemoteViews(String packageName, int userId, int layoutId)
packageName
- Name of the package that contains the layout resource.userId
- The user under which the package is running.layoutId
- The id of the layout resource.protected RemoteViews(ApplicationInfo application, int layoutId)
application
- The application whose content is shown by the views.layoutId
- The id of the layout resource.public RemoteViews(RemoteViews landscape, RemoteViews portrait)
landscape
- The RemoteViews to inflate in landscape configurationportrait
- The RemoteViews to inflate in portrait configurationpublic RemoteViews(Parcel parcel)
parcel
- public void setRemoteInputs(int viewId, RemoteInput[] remoteInputs)
public void mergeRemoteViews(RemoteViews newRv)
newRv
- public RemoteViews clone()
Object
x
, the expression:
will be true, and that the expression:x.clone() != x
will bex.clone().getClass() == x.getClass()
true
, but these are not absolute requirements.
While it is typically the case that:
will bex.clone().equals(x)
true
, this is not an absolute requirement.
By convention, the returned object should be obtained by calling
super.clone
. If a class and all of its superclasses (except
Object
) obey this convention, it will be the case that
x.clone().getClass() == x.getClass()
.
By convention, the object returned by this method should be independent
of this object (which is being cloned). To achieve this independence,
it may be necessary to modify one or more fields of the object returned
by super.clone
before returning it. Typically, this means
copying any mutable objects that comprise the internal "deep structure"
of the object being cloned and replacing the references to these
objects with references to the copies. If a class contains only
primitive fields or references to immutable objects, then it is usually
the case that no fields in the object returned by super.clone
need to be modified.
The method clone
for class Object
performs a
specific cloning operation. First, if the class of this object does
not implement the interface Cloneable
, then a
CloneNotSupportedException
is thrown. Note that all arrays
are considered to implement the interface Cloneable
and that
the return type of the clone
method of an array type T[]
is T[]
where T is any reference or primitive type.
Otherwise, this method creates a new instance of the class of this
object and initializes all its fields with exactly the contents of
the corresponding fields of this object, as if by assignment; the
contents of the fields are not themselves cloned. Thus, this method
performs a "shallow copy" of this object, not a "deep copy" operation.
The class Object
does not itself implement the interface
Cloneable
, so calling the clone
method on an object
whose class is Object
will result in throwing an
exception at run time.
public String getPackage()
public int getLayoutId()
public int estimateMemoryUsage()
public void addView(int viewId, RemoteViews nestedView)
ViewGroup.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.public void removeAllViews(int viewId)
ViewGroup.removeAllViews()
.viewId
- The id of the parent ViewGroup
to remove all
children from.public void showNext(int viewId)
AdapterViewAnimator.showNext()
viewId
- The id of the view on which to call AdapterViewAnimator.showNext()
public void showPrevious(int viewId)
AdapterViewAnimator.showPrevious()
viewId
- The id of the view on which to call AdapterViewAnimator.showPrevious()
public void setDisplayedChild(int viewId, int childIndex)
AdapterViewAnimator.setDisplayedChild(int)
viewId
- The id of the view on which to call
AdapterViewAnimator.setDisplayedChild(int)
public void setViewVisibility(int viewId, int visibility)
viewId
- The id of the view whose visibility should changevisibility
- The new visibility for the viewpublic void setTextViewText(int viewId, CharSequence text)
viewId
- The id of the view whose text should changetext
- The new text for the viewpublic void setTextViewTextSize(int viewId, int units, float size)
TextView.setTextSize(int, float)
viewId
- The id of the view whose text size should changeunits
- The units of size (e.g. COMPLEX_UNIT_SP)size
- The size of the textpublic void setTextViewCompoundDrawables(int viewId, int left, int top, int right, int bottom)
TextView.setCompoundDrawablesWithIntrinsicBounds(int, int, int, int)
.viewId
- The id of the view whose text should changeleft
- The id of a drawable to place to the left of the text, or 0top
- The id of a drawable to place above the text, or 0right
- The id of a drawable to place to the right of the text, or 0bottom
- The id of a drawable to place below the text, or 0public void setTextViewCompoundDrawablesRelative(int viewId, int start, int top, int end, int bottom)
TextView.setCompoundDrawablesRelativeWithIntrinsicBounds(int, int, int, int)
.viewId
- The id of the view whose text should changestart
- The id of a drawable to place before the text (relative to the
layout direction), or 0top
- The id of a drawable to place above the text, or 0end
- The id of a drawable to place after the text, or 0bottom
- The id of a drawable to place below the text, or 0public void setTextViewCompoundDrawablesRelativeColorFilter(int viewId, int index, int color, PorterDuff.Mode mode)
TextView.getCompoundDrawablesRelative()
.viewId
- The id of the view whose text should change.index
- The index of the drawable in the array of
TextView.getCompoundDrawablesRelative()
to set the color
filter on. Must be in [0, 3].color
- The color of the color filter. See
Drawable.setColorFilter(int, android.graphics.PorterDuff.Mode)
.mode
- The mode of the color filter. See
Drawable.setColorFilter(int, android.graphics.PorterDuff.Mode)
.public void setTextViewCompoundDrawables(int viewId, Icon left, Icon top, Icon right, Icon bottom)
TextView.setCompoundDrawablesWithIntrinsicBounds(Drawable, Drawable, Drawable, Drawable)
using the drawables yielded by Icon.loadDrawable(Context)
.viewId
- The id of the view whose text should changeleft
- an Icon to place to the left of the text, or 0top
- an Icon to place above the text, or 0right
- an Icon to place to the right of the text, or 0bottom
- an Icon to place below the text, or 0public void setTextViewCompoundDrawablesRelative(int viewId, Icon start, Icon top, Icon end, Icon bottom)
TextView.setCompoundDrawablesRelativeWithIntrinsicBounds(Drawable, Drawable, Drawable, Drawable)
using the drawables yielded by Icon.loadDrawable(Context)
.viewId
- The id of the view whose text should changestart
- an Icon to place before the text (relative to the
layout direction), or 0top
- an Icon to place above the text, or 0end
- an Icon to place after the text, or 0bottom
- an Icon to place below the text, or 0public void setImageViewResource(int viewId, int srcId)
viewId
- The id of the view whose drawable should changesrcId
- The new resource id for the drawablepublic void setImageViewUri(int viewId, Uri uri)
viewId
- The id of the view whose drawable should changeuri
- The Uri for the imagepublic void setImageViewBitmap(int viewId, Bitmap bitmap)
viewId
- The id of the view whose bitmap should changebitmap
- The new Bitmap for the drawablepublic void setImageViewIcon(int viewId, Icon icon)
viewId
- The id of the view whose bitmap should changeicon
- The new Icon for the ImageViewpublic void setEmptyView(int viewId, int emptyViewId)
viewId
- The id of the view on which to set the empty viewemptyViewId
- The view id of the empty viewpublic void setChronometer(int viewId, long base, String format, boolean started)
Chronometer.setBase
,
Chronometer.setFormat
,
and Chronometer.start()
or
Chronometer.stop()
.viewId
- The id of the Chronometer
to changebase
- 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.setChronometerCountDown(int, boolean)
public void setChronometerCountDown(int viewId, boolean isCountDown)
Chronometer.setCountDown
on
the chronometer with the given viewId.viewId
- The id of the Chronometer
to changeisCountDown
- True if you want the chronometer to count down to base instead of
counting up.public void setProgressBar(int viewId, int max, int progress, boolean indeterminate)
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 changemax
- The 100% value for the progress barprogress
- The current value of the progress bar.indeterminate
- True if the progress bar is indeterminate,
false if not.public void setOnClickPendingIntent(int viewId, PendingIntent pendingIntent)
View.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 clickedpendingIntent
- The PendingIntent
to send when user clickspublic void setPendingIntentTemplate(int viewId, PendingIntent pendingIntentTemplate)
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 clickedpendingIntentTemplate
- The PendingIntent
to be combined with extras specified
by a child of viewId and executed when that child is clickedpublic void setOnClickFillInIntent(int viewId, Intent fillInIntent)
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 Intent.fillIn(Intent, int)
for more details.viewId
- The id of the view on which to set the fillInIntentfillInIntent
- The intent which will be combined with the parent's PendingIntent
in order to determine the on-click behavior of the view specified by viewIdpublic void setDrawableParameters(int viewId, boolean targetBackground, int alpha, int colorFilter, PorterDuff.Mode mode, int level)
viewId
- The id of the view that contains the target
Drawable
targetBackground
- If true, apply these parameters to the
Drawable
returned by
View.getBackground()
. Otherwise, assume
the target view is an ImageView
and apply them to
ImageView.getDrawable()
.alpha
- Specify an alpha value for the drawable, or -1 to leave
unchanged.colorFilter
- Specify a color for a
ColorFilter
for this drawable. This will be ignored if
mode
is null
.mode
- Specify a PorterDuff mode for this drawable, or null to leave
unchanged.level
- Specify the level for the drawable, or -1 to leave
unchanged.public void setProgressTintList(int viewId, ColorStateList tint)
viewId
- The id of the view whose tint should changetint
- the tint to apply, may be null
to clear tintpublic void setProgressBackgroundTintList(int viewId, ColorStateList tint)
viewId
- The id of the view whose tint should changetint
- the tint to apply, may be null
to clear tintpublic void setProgressIndeterminateTintList(int viewId, ColorStateList tint)
viewId
- The id of the view whose tint should changetint
- the tint to apply, may be null
to clear tintpublic void setTextColor(int viewId, int color)
TextView.setTextColor(int)
.viewId
- The id of the view whose text color should changecolor
- Sets the text color for all the states (normal, selected,
focused) to be this color.public void setTextColor(int viewId, ColorStateList colors)
viewId
- The id of the view whose text color should changecolors
- the text colors to set@Deprecated public void setRemoteAdapter(int appWidgetId, int viewId, Intent intent)
setRemoteAdapter(int, Intent)
AbsListView.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 RemoteViewsAdapterpublic void setRemoteAdapter(int viewId, Intent intent)
AbsListView.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 RemoteViewsAdapterpublic void setRemoteAdapter(int viewId, ArrayList<RemoteViews> list, int viewTypeCount)
ListView
, GridView
, StackView
or AdapterViewAnimator
.
This is a simpler but less flexible approach to populating collection widgets. Its use is
encouraged for most scenarios, as long as the total memory within the list of RemoteViews
is relatively small (ie. doesn't contain large or numerous Bitmaps, see setImageViewBitmap(int, android.graphics.Bitmap)
). In the case of numerous images, the use of API is still
possible by setting image URIs instead of Bitmaps, see setImageViewUri(int, android.net.Uri)
.
This API is supported in the compatibility library for previous API levels, see
RemoteViewsCompat.viewId
- The id of the AdapterView
list
- The list of RemoteViews which will populate the view specified by viewId.viewTypeCount
- The maximum number of unique layout id's used to construct the list of
RemoteViews. This count cannot change during the life-cycle of a given widget, so this
parameter should account for the maximum possible number of types that may appear in the
See Adapter.getViewTypeCount()
.public void setScrollPosition(int viewId, int position)
AbsListView.smoothScrollToPosition(int, int)
.viewId
- The id of the view to changeposition
- Scroll to this adapter positionpublic void setRelativeScrollPosition(int viewId, int offset)
AbsListView.smoothScrollToPosition(int, int)
.viewId
- The id of the view to changeoffset
- Scroll by this adapter position offsetpublic void setViewPadding(int viewId, int left, int top, int right, int bottom)
View.setPadding(int, int, int, int)
.viewId
- The id of the view to changeleft
- the left padding in pixelstop
- the top padding in pixelsright
- the right padding in pixelsbottom
- the bottom padding in pixelspublic void setViewLayoutMarginEndDimen(int viewId, @DimenRes int endMarginDimen)
viewId
- The id of the view to changeendMarginDimen
- a dimen resource to read the margin from or 0 to clear the margin.public void setViewLayoutMarginBottomDimen(int viewId, @DimenRes int bottomMarginDimen)
ViewGroup.MarginLayoutParams.bottomMargin
.bottomMarginDimen
- a dimen resource to read the margin from or 0 to clear the margin.public void setViewLayoutWidth(int viewId, int layoutWidth)
ViewGroup.LayoutParams.width
.layoutWidth
- one of 0, MATCH_PARENT or WRAP_CONTENT. Other sizes are not allowed
because they behave poorly when the density changes.public void setBoolean(int viewId, String methodName, boolean value)
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.public void setByte(int viewId, String methodName, byte value)
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.public void setShort(int viewId, String methodName, short value)
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.public void setInt(int viewId, String methodName, int value)
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.public void setLong(int viewId, String methodName, long value)
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.public void setFloat(int viewId, String methodName, float value)
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.public void setDouble(int viewId, String methodName, double value)
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.public void setChar(int viewId, String methodName, char value)
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.public void setString(int viewId, String methodName, String value)
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.public void setCharSequence(int viewId, String methodName, CharSequence value)
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.public void setUri(int viewId, String methodName, Uri value)
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.public void setBitmap(int viewId, String methodName, Bitmap value)
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.public void setBundle(int viewId, String methodName, Bundle value)
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.public void setIntent(int viewId, String methodName, Intent value)
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.public void setIcon(int viewId, String methodName, Icon value)
viewId
- The id of the view on which to call the method.methodName
- The name of the method to call.value
- The Icon
to pass the method.public void setContentDescription(int viewId, CharSequence contentDescription)
viewId
- The id of the view whose content description should change.contentDescription
- The new content description for the view.public void setAccessibilityTraversalBefore(int viewId, int nextId)
View.setAccessibilityTraversalBefore(int)
.viewId
- The id of the view whose before view in accessibility traversal to set.nextId
- The id of the next in the accessibility traversal.public void setAccessibilityTraversalAfter(int viewId, int nextId)
View.setAccessibilityTraversalAfter(int)
.viewId
- The id of the view whose after view in accessibility traversal to set.nextId
- The id of the next in the accessibility traversal.public void setLabelFor(int viewId, int labeledId)
viewId
- The id of the view whose property to set.labeledId
- The id of a view for which this view serves as a label.public View apply(Context context, ViewGroup parent)
Caller beware: this may throw
context
- Default context to useparent
- Parent that the resulting view hierarchy will be attached to. This method
does not attach the hierarchy. The caller should do so when appropriate.public View apply(Context context, ViewGroup parent, RemoteViews.OnClickHandler handler)
public CancellationSignal applyAsync(Context context, ViewGroup parent, Executor executor, RemoteViews.OnViewAppliedListener listener)
context
- Default context to useparent
- Parent that the resulting view hierarchy will be attached to. This method
does not attach the hierarchy. The caller should do so when appropriate.listener
- the callback to run when all actions have been applied. May be null.executor
- The executor to use. If null AsyncTask.THREAD_POOL_EXECUTOR
is used.#apply(Context, ViewGroup)}
public CancellationSignal applyAsync(Context context, ViewGroup parent, Executor executor, RemoteViews.OnViewAppliedListener listener, RemoteViews.OnClickHandler handler)
public void reapply(Context context, View v)
Caller beware: this may throw
v
- The view to apply the actions to. This should be the result of
the apply(Context,ViewGroup)
call.public void reapply(Context context, View v, RemoteViews.OnClickHandler handler)
public CancellationSignal reapplyAsync(Context context, View v, Executor executor, RemoteViews.OnViewAppliedListener listener)
context
- Default context to usev
- The view to apply the actions to. This should be the result of
the apply(Context,ViewGroup)
call.listener
- the callback to run when all actions have been applied. May be null.executor
- The executor to use. If null AsyncTask.THREAD_POOL_EXECUTOR
is used#reapply(Context, View)}
public CancellationSignal reapplyAsync(Context context, View v, Executor executor, RemoteViews.OnViewAppliedListener listener, RemoteViews.OnClickHandler handler)
public int getSequenceNumber()
public boolean onLoadClass(Class clazz)
LayoutInflater.Filter
onLoadClass
in interface LayoutInflater.Filter
clazz
- The class object for the View that is about to be inflatedpublic int describeContents()
Parcelable
Parcelable.writeToParcel(Parcel, int)
,
the return value of this method must include the
Parcelable.CONTENTS_FILE_DESCRIPTOR
bit.describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR
public void writeToParcel(Parcel dest, int flags)
Parcelable
writeToParcel
in interface Parcelable
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.PARCELABLE_WRITE_RETURN_VALUE
.