RemoteViews
public
class
RemoteViews
extends Object
implements
LayoutInflater.Filter,
Parcelable
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.
RemoteViews
is limited to support for the following layouts:
AdapterViewFlipper
FrameLayout
GridLayout
GridView
LinearLayout
ListView
RelativeLayout
StackView
ViewFlipper
And the following widgets:
As of API 31, the following widgets and layouts may also be used:
Descendants of these classes are not supported.
Summary
Nested classes | |
---|---|
class |
RemoteViews.ActionException
Exception to send when something goes wrong executing an action |
class |
RemoteViews.DrawInstructions
A data parcel that carries the instructions to draw the RemoteViews, as an alternative to XML layout. |
class |
RemoteViews.RemoteCollectionItems
Representation of a fixed list of items to be displayed in a RemoteViews collection. |
class |
RemoteViews.RemoteResponse
Class representing a response to an action performed on any element of a RemoteViews. |
class |
RemoteViews.RemoteViewOutlineProvider
OutlineProvider for a view with a radius set by
|
Constants | |
---|---|
String |
EXTRA_CHECKED
The intent extra for whether the view whose checked state changed is currently checked. |
String |
EXTRA_SHARED_ELEMENT_BOUNDS
The intent extra that contains the bounds for all shared elements. |
int |
MARGIN_BOTTOM
The value will apply to the marginBottom. |
int |
MARGIN_END
The value will apply to the marginEnd. |
int |
MARGIN_LEFT
The value will apply to the marginLeft. |
int |
MARGIN_RIGHT
The value will apply to the marginRight. |
int |
MARGIN_START
The value will apply to the marginStart. |
int |
MARGIN_TOP
The value will apply to the marginTop. |
Inherited constants |
---|
Fields | |
---|---|
public
static
final
Creator<RemoteViews> |
CREATOR
Parcelable.Creator that instantiates RemoteViews objects |
Public constructors | |
---|---|
RemoteViews(Parcel parcel)
Reads a RemoteViews object from a parcel. |
|
RemoteViews(RemoteViews src)
Creates a copy of another RemoteViews. |
|
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(RemoteViews.DrawInstructions drawInstructions)
Instantiates a RemoteViews object using |
|
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 layoutId, int viewId)
Create a new RemoteViews object that will display the views contained in the specified layout file and change the id of the root view to the specified one. |
|
RemoteViews(Map<SizeF, RemoteViews> remoteViews)
Create a new RemoteViews object that will inflate the layout with the closest size specification. |
Public methods | |
---|---|
void
|
addStableView(int viewId, RemoteViews nestedView, int stableId)
Equivalent to calling |
void
|
addView(int viewId, RemoteViews nestedView)
Equivalent to calling |
View
|
apply(Context context, ViewGroup parent)
Inflates the view hierarchy represented by this object and applies all of the actions. |
RemoteViews
|
clone()
This method was deprecated
in API level 28.
use |
int
|
describeContents()
Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
int
|
getLayoutId()
Returns the layout id of the root layout associated with this RemoteViews. |
String
|
getPackage()
|
int
|
getViewId()
Get the ID of the top-level view of the XML layout, if set using
|
boolean
|
onLoadClass(Class<T> clazz)
This method is deprecated.
Used by system to enforce safe inflation of |
void
|
reapply(Context context, View v)
Applies all of the actions to the provided view. |
void
|
removeAllViews(int viewId)
Equivalent to calling |
void
|
setAccessibilityTraversalAfter(int viewId, int nextId)
Equivalent to calling |
void
|
setAccessibilityTraversalBefore(int viewId, int nextId)
Equivalent to calling |
void
|
setBitmap(int viewId, String methodName, Bitmap value)
Call a method taking one Bitmap on a view in the layout for this RemoteViews. |
void
|
setBlendMode(int viewId, String methodName, BlendMode value)
Call a method taking one BlendMode 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, int stringResource)
Call a method taking one CharSequence 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
|
setCharSequenceAttr(int viewId, String methodName, int stringAttribute)
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 |
void
|
setChronometerCountDown(int viewId, boolean isCountDown)
Equivalent to calling |
void
|
setColor(int viewId, String methodName, int colorResource)
Call a method taking one int, a color, on a view in the layout for this RemoteViews. |
void
|
setColorAttr(int viewId, String methodName, int colorAttribute)
Call a method taking one int, a color, on a view in the layout for this RemoteViews. |
void
|
setColorInt(int viewId, String methodName, int notNight, int night)
Call a method taking one int, a color, on a view in the layout for this RemoteViews. |
void
|
setColorStateList(int viewId, String methodName, ColorStateList notNight, ColorStateList night)
Call a method taking one ColorStateList on a view in the layout for this RemoteViews. |
void
|
setColorStateList(int viewId, String methodName, ColorStateList value)
Call a method taking one ColorStateList on a view in the layout for this RemoteViews. |
void
|
setColorStateList(int viewId, String methodName, int colorResource)
Call a method taking one ColorStateList on a view in the layout for this RemoteViews. |
void
|
setColorStateListAttr(int viewId, String methodName, int colorAttr)
Call a method taking one ColorStateList on a view in the layout for this RemoteViews. |
void
|
setCompoundButtonChecked(int viewId, boolean checked)
Equivalent to calling |
void
|
setContentDescription(int viewId, CharSequence contentDescription)
Equivalent to calling View.setContentDescription(CharSequence). |
void
|
setDisplayedChild(int viewId, int childIndex)
Equivalent to calling |
void
|
setDouble(int viewId, String methodName, double value)
Call a method taking one double on a view in the layout for this RemoteViews. |
void
|
setEmptyView(int viewId, int emptyViewId)
Equivalent to calling |
void
|
setFloat(int viewId, String methodName, float value)
Call a method taking one float on a view in the layout for this RemoteViews. |
void
|
setFloatDimen(int viewId, String methodName, int dimenResource)
Call a method taking one float, a size in pixels, on a view in the layout for this RemoteViews. |
void
|
setFloatDimen(int viewId, String methodName, float value, int unit)
Call a method taking one float, a size in pixels, on a view in the layout for this RemoteViews. |
void
|
setFloatDimenAttr(int viewId, String methodName, int dimenAttr)
Call a method taking one float, a size in pixels, 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
|
setIcon(int viewId, String methodName, Icon notNight, Icon night)
Call a method taking one Icon on a view in the layout for this RemoteViews. |
void
|
setImageViewBitmap(int viewId, Bitmap bitmap)
Equivalent to calling |
void
|
setImageViewIcon(int viewId, Icon icon)
Equivalent to calling |
void
|
setImageViewResource(int viewId, int srcId)
Equivalent to calling |
void
|
setImageViewUri(int viewId, Uri uri)
Equivalent to calling |
void
|
setInt(int viewId, String methodName, int value)
Call a method taking one int on a view in the layout for this RemoteViews. |
void
|
setIntDimen(int viewId, String methodName, float value, int unit)
Call a method taking one int, a size in pixels, on a view in the layout for this RemoteViews. |
void
|
setIntDimen(int viewId, String methodName, int dimenResource)
Call a method taking one int, a size in pixels, on a view in the layout for this RemoteViews. |
void
|
setIntDimenAttr(int viewId, String methodName, int dimenAttr)
Call a method taking one int, a size in pixels, 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 |
void
|
setLightBackgroundLayoutId(int layoutId)
Provides an alternate layout ID, which can be used to inflate this view. |
void
|
setLong(int viewId, String methodName, long value)
Call a method taking one long on a view in the layout for this RemoteViews. |
void
|
setOnCheckedChangeResponse(int viewId, RemoteViews.RemoteResponse response)
Equivalent to calling
|
void
|
setOnClickFillInIntent(int viewId, Intent fillInIntent)
When using collections (eg. |
void
|
setOnClickPendingIntent(int viewId, PendingIntent pendingIntent)
Equivalent to calling
|
void
|
setOnClickResponse(int viewId, RemoteViews.RemoteResponse response)
Equivalent of calling
|
void
|
setOnStylusHandwritingPendingIntent(int viewId, PendingIntent pendingIntent)
Equivalent to calling |
void
|
setPendingIntentTemplate(int viewId, PendingIntent pendingIntentTemplate)
When using collections (eg. |
void
|
setProgressBar(int viewId, int max, int progress, boolean indeterminate)
Equivalent to calling |
void
|
setRadioGroupChecked(int viewId, int checkedId)
Equivalent to calling |
void
|
setRelativeScrollPosition(int viewId, int offset)
Equivalent to calling |
void
|
setRemoteAdapter(int appWidgetId, int viewId, Intent intent)
This method was deprecated
in API level 15.
This method has been deprecated. See
|
void
|
setRemoteAdapter(int viewId, Intent intent)
This method was deprecated
in API level 35.
use
|
void
|
setRemoteAdapter(int viewId, RemoteViews.RemoteCollectionItems items)
Creates a simple Adapter for the viewId specified. |
void
|
setScrollPosition(int viewId, int position)
Equivalent to calling |
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, int color)
Equivalent to calling |
void
|
setTextViewCompoundDrawables(int viewId, int left, int top, int right, int bottom)
Equivalent to calling
|
void
|
setTextViewCompoundDrawablesRelative(int viewId, int start, int top, int end, int bottom)
Equivalent to calling |
void
|
setTextViewText(int viewId, CharSequence text)
Equivalent to calling |
void
|
setTextViewTextSize(int viewId, int units, float size)
Equivalent to calling |
void
|
setUri(int viewId, String methodName, Uri value)
Call a method taking one Uri on a view in the layout for this RemoteViews. |
void
|
setViewLayoutHeight(int viewId, float height, int units)
Equivalent to setting |
void
|
setViewLayoutHeightAttr(int viewId, int heightAttr)
Equivalent to setting |
void
|
setViewLayoutHeightDimen(int viewId, int heightDimen)
Equivalent to setting |
void
|
setViewLayoutMargin(int viewId, int type, float value, int units)
Equivalent to calling |
void
|
setViewLayoutMarginAttr(int viewId, int type, int attr)
Equivalent to calling |
void
|
setViewLayoutMarginDimen(int viewId, int type, int dimen)
Equivalent to calling |
void
|
setViewLayoutWidth(int viewId, float width, int units)
Equivalent to setting |
void
|
setViewLayoutWidthAttr(int viewId, int widthAttr)
Equivalent to setting |
void
|
setViewLayoutWidthDimen(int viewId, int widthDimen)
Equivalent to setting |
void
|
setViewOutlinePreferredRadius(int viewId, float radius, int units)
Sets an OutlineProvider on the view whose corner radius is a dimension calculated using
|
void
|
setViewOutlinePreferredRadiusAttr(int viewId, int attrId)
Sets an OutlineProvider on the view whose corner radius is a dimension attribute with
|
void
|
setViewOutlinePreferredRadiusDimen(int viewId, int resId)
Sets an OutlineProvider on the view whose corner radius is a dimension resource with
|
void
|
setViewPadding(int viewId, int left, int top, int right, int bottom)
Equivalent to calling |
void
|
setViewVisibility(int viewId, int visibility)
Equivalent to calling |
void
|
showNext(int viewId)
This method was deprecated
in API level 33.
As RemoteViews may be reapplied frequently, it is preferable to call
|
void
|
showPrevious(int viewId)
This method was deprecated
in API level 33.
As RemoteViews may be reapplied frequently, it is preferable to call
|
void
|
writeToParcel(Parcel dest, int flags)
Flatten this object in to a Parcel. |
Inherited methods | |
---|---|
Constants
EXTRA_CHECKED
public static final String EXTRA_CHECKED
The intent extra for whether the view whose checked state changed is currently checked.
Constant Value: "android.widget.extra.CHECKED"
EXTRA_SHARED_ELEMENT_BOUNDS
public static final String EXTRA_SHARED_ELEMENT_BOUNDS
The intent extra that contains the bounds for all shared elements.
Constant Value: "android.widget.extra.SHARED_ELEMENT_BOUNDS"
MARGIN_BOTTOM
public static final int MARGIN_BOTTOM
The value will apply to the marginBottom.
Constant Value: 3 (0x00000003)
MARGIN_END
public static final int MARGIN_END
The value will apply to the marginEnd.
Constant Value: 5 (0x00000005)
MARGIN_LEFT
public static final int MARGIN_LEFT
The value will apply to the marginLeft.
Constant Value: 0 (0x00000000)
MARGIN_RIGHT
public static final int MARGIN_RIGHT
The value will apply to the marginRight.
Constant Value: 2 (0x00000002)
MARGIN_START
public static final int MARGIN_START
The value will apply to the marginStart.
Constant Value: 4 (0x00000004)
MARGIN_TOP
public static final int MARGIN_TOP
The value will apply to the marginTop.
Constant Value: 1 (0x00000001)
Fields
CREATOR
public static final Creator<RemoteViews> CREATOR
Parcelable.Creator that instantiates RemoteViews objects
Public constructors
RemoteViews
public RemoteViews (Parcel parcel)
Reads a RemoteViews object from a parcel.
Parameters | |
---|---|
parcel |
Parcel : the parcel object |
RemoteViews
public RemoteViews (RemoteViews src)
Creates a copy of another RemoteViews.
Parameters | |
---|---|
src |
RemoteViews |
RemoteViews
public 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.
Parameters | |
---|---|
landscape |
RemoteViews : The RemoteViews to inflate in landscape configuration |
portrait |
RemoteViews : The RemoteViews to inflate in portrait configuration |
Throws | |
---|---|
IllegalArgumentException |
if either landscape or portrait are null or if they are not from the same application |
RemoteViews
public RemoteViews (RemoteViews.DrawInstructions drawInstructions)
Instantiates a RemoteViews object using DrawInstructions
, which serves as an
alternative to XML layout. DrawInstructions
objects contains the instructions which
can be interpreted and rendered accordingly in the host process.
Parameters | |
---|---|
drawInstructions |
RemoteViews.DrawInstructions : The DrawInstructions object
This value cannot be null . |
RemoteViews
public RemoteViews (String packageName, int layoutId)
Create a new RemoteViews object that will display the views contained in the specified layout file.
Parameters | |
---|---|
packageName |
String : Name of the package that contains the layout resource |
layoutId |
int : The id of the layout resource |
RemoteViews
public RemoteViews (String packageName, int layoutId, int viewId)
Create a new RemoteViews object that will display the views contained in the specified layout file and change the id of the root view to the specified one.
Parameters | |
---|---|
packageName |
String : Name of the package that contains the layout resource
This value cannot be null . |
layoutId |
int : The id of the layout resource |
viewId |
int |
RemoteViews
public RemoteViews (Map<SizeF, RemoteViews> remoteViews)
Create a new RemoteViews object that will inflate the layout with the closest size
specification.
The default remote views in that case is always the one with the smallest area.
If the RemoteViews
host provides the size of the view, the layout with the largest
area that fits entirely in the provided size will be used (i.e. the width and height of
the layout must be less than the size of the view, with a 1dp margin to account for
rounding). If no layout fits in the view, the layout with the smallest area will be used.
Parameters | |
---|---|
remoteViews |
Map : Mapping of size to layout.
This value cannot be null . |
Throws | |
---|---|
IllegalArgumentException |
if the map is empty, there are more than MAX_INIT_VIEW_COUNT layouts or the remote views are not all from the same application. |
Public methods
addStableView
public void addStableView (int viewId, RemoteViews nestedView, int stableId)
Equivalent to calling ViewGroup.addView(View)
after inflating the given
RemoteViews
. If the RemoteViews
may be re-inflated or updated,
removeAllViews(int)
must be called on the same viewId
before the first call to this method for the behavior of this method to be predictable.
The stableId
will be used to identify a potential view to recycled when the remote
view is inflated. Views can be re-used if inserted in the same order, potentially with
some views appearing / disappearing. To be recycled the view must not change the layout
used to inflate it or its view id (see RemoteViews.RemoteViews(String, int, int)
).
Note: if a view is re-used, all the actions will be re-applied on it. However, its properties
are not reset, so what was applied in previous round will have an effect. As a view may be
re-created at any time by the host, the RemoteViews should not rely on keeping information
from previous applications and always re-set all the properties they need.
Parameters | |
---|---|
viewId |
int : The id of the parent ViewGroup to add child into. |
nestedView |
RemoteViews : RemoteViews that describes the child.
This value cannot be null . |
stableId |
int : An id that is stable across different versions of RemoteViews. |
addView
public void addView (int viewId, RemoteViews nestedView)
Equivalent to calling 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.
Parameters | |
---|---|
viewId |
int : The id of the parent ViewGroup to add child into. |
nestedView |
RemoteViews : RemoteViews that describes the child. |
apply
public View apply (Context context, ViewGroup parent)
Inflates the view hierarchy represented by this object and applies all of the actions.
Caller beware: this may throw
Parameters | |
---|---|
context |
Context : Default context to use |
parent |
ViewGroup : Parent that the resulting view hierarchy will be attached to. This method
does not attach the hierarchy. The caller should do so when appropriate. |
Returns | |
---|---|
View |
The inflated view hierarchy |
clone
public RemoteViews clone ()
This method was deprecated
in API level 28.
use RemoteViews(android.widget.RemoteViews)
instead.
Returns a deep copy of the RemoteViews object. The RemoteView may not be attached to another RemoteView -- it must be the root of a hierarchy.
Returns | |
---|---|
RemoteViews |
a clone of this instance. |
Throws | |
---|---|
IllegalStateException |
if this is not the root of a RemoteView hierarchy |
describeContents
public int describeContents ()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation. For example, if the object will
include a file descriptor in the output of writeToParcel(android.os.Parcel, int)
,
the return value of this method must include the
CONTENTS_FILE_DESCRIPTOR
bit.
Returns | |
---|---|
int |
a bitmask indicating the set of special object types marshaled
by this Parcelable object instance.
Value is either 0 or CONTENTS_FILE_DESCRIPTOR |
getLayoutId
public int getLayoutId ()
Returns 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.
Returns | |
---|---|
int |
the layout id. |
getViewId
public int getViewId ()
Get the ID of the top-level view of the XML layout, if set using
RemoteViews.RemoteViews(String, int, int)
.
Returns | |
---|---|
int |
onLoadClass
public boolean onLoadClass (Class<T> clazz)
This method is deprecated.
Used by system to enforce safe inflation of RemoteViews
. Apps should not
override this method. Changing of this method will NOT affect the process where RemoteViews
is rendered.
Used to restrict the views which can be inflated
Parameters | |
---|---|
clazz |
Class : The class object for the View that is about to be inflated |
Returns | |
---|---|
boolean |
True if this class is allowed to be inflated, or false otherwise |
reapply
public void reapply (Context context, View v)
Applies all of the actions to the provided view.
Caller beware: this may throw
Parameters | |
---|---|
context |
Context |
v |
View : The view to apply the actions to. This should be the result of
the apply(android.content.Context, android.view.ViewGroup) call. |
removeAllViews
public void removeAllViews (int viewId)
Equivalent to calling ViewGroup.removeAllViews()
.
Parameters | |
---|---|
viewId |
int : The id of the parent ViewGroup to remove all
children from. |
setAccessibilityTraversalAfter
public void setAccessibilityTraversalAfter (int viewId, int nextId)
Equivalent to calling View.setAccessibilityTraversalAfter(int)
.
Parameters | |
---|---|
viewId |
int : The id of the view whose after view in accessibility traversal to set. |
nextId |
int : The id of the next in the accessibility traversal. |
setAccessibilityTraversalBefore
public void setAccessibilityTraversalBefore (int viewId, int nextId)
Equivalent to calling View.setAccessibilityTraversalBefore(int)
.
Parameters | |
---|---|
viewId |
int : The id of the view whose before view in accessibility traversal to set. |
nextId |
int : The id of the next in the accessibility traversal. |
setBitmap
public void setBitmap (int viewId, String methodName, Bitmap value)
Call a method taking one Bitmap on a view in the layout for this RemoteViews.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call. |
value |
Bitmap : The value to pass to the method. |
setBlendMode
public void setBlendMode (int viewId, String methodName, BlendMode value)
Call a method taking one BlendMode on a view in the layout for this RemoteViews.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call.
This value cannot be null . |
value |
BlendMode : The value to pass to the method.
This value may be null . |
setBoolean
public void setBoolean (int viewId, String methodName, boolean value)
Call a method taking one boolean on a view in the layout for this RemoteViews.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call. |
value |
boolean : The value to pass to the method. |
setBundle
public void setBundle (int viewId, String methodName, Bundle value)
Call a method taking one Bundle on a view in the layout for this RemoteViews.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call. |
value |
Bundle : The value to pass to the method. |
setByte
public void setByte (int viewId, String methodName, byte value)
Call a method taking one byte on a view in the layout for this RemoteViews.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call. |
value |
byte : The value to pass to the method. |
setChar
public void setChar (int viewId, String methodName, char value)
Call a method taking one char on a view in the layout for this RemoteViews.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call. |
value |
char : The value to pass to the method. |
setCharSequence
public void setCharSequence (int viewId, String methodName, int stringResource)
Call a method taking one CharSequence on a view in the layout for this RemoteViews.
The CharSequence will be resolved from the resources at the time the RemoteViews
is
(re-)applied.
Undefined resources will result in an exception, except 0 which will resolve to null.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call.
This value cannot be null . |
stringResource |
int : The resource to resolve and pass as argument to the method. |
setCharSequence
public void setCharSequence (int viewId, String methodName, CharSequence value)
Call a method taking one CharSequence on a view in the layout for this RemoteViews.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call. |
value |
CharSequence : The value to pass to the method. |
setCharSequenceAttr
public void setCharSequenceAttr (int viewId, String methodName, int stringAttribute)
Call a method taking one CharSequence on a view in the layout for this RemoteViews.
The CharSequence will be resolved from the theme attribute at the time the
RemoteViews
is (re-)applied.
Unresolvable attributes will result in an exception, except 0 which will resolve to null.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call.
This value cannot be null . |
stringAttribute |
int : The attribute to resolve and pass as argument to the method. |
setChronometer
public void setChronometer (int viewId, long base, String format, boolean started)
Equivalent to calling Chronometer.setBase
,
Chronometer.setFormat
,
and Chronometer.start()
or
Chronometer.stop()
.
Parameters | |
---|---|
viewId |
int : The id of the Chronometer to change |
base |
long : The time at which the timer would have read 0:00. This
time should be based off of
SystemClock.elapsedRealtime() . |
format |
String : The Chronometer format string, or null to
simply display the timer value. |
started |
boolean : True if you want the clock to be started, false if not. |
See also:
setChronometerCountDown
public void setChronometerCountDown (int viewId, boolean isCountDown)
Equivalent to calling Chronometer.setCountDown
on
the chronometer with the given viewId.
Parameters | |
---|---|
viewId |
int : The id of the Chronometer to change |
isCountDown |
boolean : True if you want the chronometer to count down to base instead of
counting up. |
setColor
public void setColor (int viewId, String methodName, int colorResource)
Call a method taking one int, a color, on a view in the layout for this RemoteViews.
The Color will be resolved from the resources at the time the RemoteViews
is (re-)
applied.
Undefined resources will result in an exception, except 0 which will resolve to 0.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call.
This value cannot be null . |
colorResource |
int : The resource to resolve and pass as argument to the method. |
setColorAttr
public void setColorAttr (int viewId, String methodName, int colorAttribute)
Call a method taking one int, a color, on a view in the layout for this RemoteViews.
The Color will be resolved from the theme attribute at the time the RemoteViews
is
(re-)applied.
Unresolvable attributes will result in an exception, except 0 which will resolve to 0.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call.
This value cannot be null . |
colorAttribute |
int : The theme attribute to resolve and pass as argument to the method. |
setColorInt
public void setColorInt (int viewId, String methodName, int notNight, int night)
Call a method taking one int, a color, on a view in the layout for this RemoteViews.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call.
This value cannot be null . |
notNight |
int : The value to pass to the method when the view's configuration is set to
Configuration.UI_MODE_NIGHT_NO |
night |
int : The value to pass to the method when the view's configuration is set to
Configuration.UI_MODE_NIGHT_YES |
setColorStateList
public void setColorStateList (int viewId, String methodName, ColorStateList notNight, ColorStateList night)
Call a method taking one ColorStateList on a view in the layout for this RemoteViews.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call.
This value cannot be null . |
notNight |
ColorStateList : The value to pass to the method when the view's configuration is set to
Configuration.UI_MODE_NIGHT_NO
This value may be null . |
night |
ColorStateList : The value to pass to the method when the view's configuration is set to
Configuration.UI_MODE_NIGHT_YES
This value may be null . |
setColorStateList
public void setColorStateList (int viewId, String methodName, ColorStateList value)
Call a method taking one ColorStateList on a view in the layout for this RemoteViews.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call.
This value cannot be null . |
value |
ColorStateList : The value to pass to the method.
This value may be null . |
setColorStateList
public void setColorStateList (int viewId, String methodName, int colorResource)
Call a method taking one ColorStateList on a view in the layout for this RemoteViews.
The ColorStateList will be resolved from the resources at the time the RemoteViews
is
(re-)applied.
Undefined resources will result in an exception, except 0 which will resolve to null.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call.
This value cannot be null . |
colorResource |
int : The resource to resolve and pass as argument to the method. |
setColorStateListAttr
public void setColorStateListAttr (int viewId, String methodName, int colorAttr)
Call a method taking one ColorStateList on a view in the layout for this RemoteViews.
The ColorStateList will be resolved from the theme attribute at the time the
RemoteViews
is (re-)applied.
Unresolvable attributes will result in an exception, except 0 which will resolve to null.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call.
This value cannot be null . |
colorAttr |
int : The theme attribute to resolve and pass as argument to the method. |
setCompoundButtonChecked
public void setCompoundButtonChecked (int viewId, boolean checked)
Equivalent to calling CompoundButton.setChecked(boolean)
.
Parameters | |
---|---|
viewId |
int : The id of the view whose property to set. |
checked |
boolean : true to check the button, false to uncheck it. |
setContentDescription
public void setContentDescription (int viewId, CharSequence contentDescription)
Equivalent to calling View.setContentDescription(CharSequence).
Parameters | |
---|---|
viewId |
int : The id of the view whose content description should change. |
contentDescription |
CharSequence : The new content description for the view. |
setDisplayedChild
public void setDisplayedChild (int viewId, int childIndex)
Equivalent to calling AdapterViewAnimator.setDisplayedChild(int)
Parameters | |
---|---|
viewId |
int : The id of the view on which to call
AdapterViewAnimator.setDisplayedChild(int) |
childIndex |
int |
setDouble
public void setDouble (int viewId, String methodName, double value)
Call a method taking one double on a view in the layout for this RemoteViews.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call. |
value |
double : The value to pass to the method. |
setEmptyView
public void setEmptyView (int viewId, int emptyViewId)
Equivalent to calling AdapterView.setEmptyView(View)
Parameters | |
---|---|
viewId |
int : The id of the view on which to set the empty view |
emptyViewId |
int : The view id of the empty view |
setFloat
public void setFloat (int viewId, String methodName, float value)
Call a method taking one float on a view in the layout for this RemoteViews.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call. |
value |
float : The value to pass to the method. |
setFloatDimen
public void setFloatDimen (int viewId, String methodName, int dimenResource)
Call a method taking one float, a size in pixels, on a view in the layout for this
RemoteViews.
The dimension will be resolved from the resources at the time the RemoteViews
is
(re-)applied.
Undefined resources will result in an exception, except 0 which will resolve to 0f.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call.
This value cannot be null . |
dimenResource |
int : The resource to resolve and pass as argument to the method. |
setFloatDimen
public void setFloatDimen (int viewId, String methodName, float value, int unit)
Call a method taking one float, a size in pixels, on a view in the layout for this
RemoteViews.
The dimension will be resolved from the resources at the time the RemoteViews
is
(re-)applied.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call.
This value cannot be null . |
value |
float : The value of the dimension. |
unit |
int : The unit in which the value is specified.
Value is TypedValue.COMPLEX_UNIT_PX , TypedValue.COMPLEX_UNIT_DIP , TypedValue.COMPLEX_UNIT_SP , TypedValue.COMPLEX_UNIT_PT , TypedValue.COMPLEX_UNIT_IN , or TypedValue.COMPLEX_UNIT_MM |
setFloatDimenAttr
public void setFloatDimenAttr (int viewId, String methodName, int dimenAttr)
Call a method taking one float, a size in pixels, on a view in the layout for this
RemoteViews.
The dimension will be resolved from the theme attribute at the time the RemoteViews
is (re-)applied.
Unresolvable attributes will result in an exception, except 0 which will resolve to 0f.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call.
This value cannot be null . |
dimenAttr |
int : The attribute to resolve and pass as argument to the method. |
setIcon
public void setIcon (int viewId, String methodName, Icon value)
Call a method taking one Icon on a view in the layout for this RemoteViews.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call. |
value |
Icon : The Icon to pass the method. |
setIcon
public void setIcon (int viewId, String methodName, Icon notNight, Icon night)
Call a method taking one Icon on a view in the layout for this RemoteViews.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call.
This value cannot be null . |
notNight |
Icon : The value to pass to the method when the view's configuration is set to
Configuration.UI_MODE_NIGHT_NO
This value may be null . |
night |
Icon : The value to pass to the method when the view's configuration is set to
Configuration.UI_MODE_NIGHT_YES
This value may be null . |
setImageViewBitmap
public void setImageViewBitmap (int viewId, Bitmap bitmap)
Equivalent to calling ImageView.setImageBitmap(Bitmap)
Parameters | |
---|---|
viewId |
int : The id of the view whose bitmap should change |
bitmap |
Bitmap : The new Bitmap for the drawable |
setImageViewIcon
public void setImageViewIcon (int viewId, Icon icon)
Equivalent to calling ImageView.setImageIcon(Icon)
Parameters | |
---|---|
viewId |
int : The id of the view whose bitmap should change |
icon |
Icon : The new Icon for the ImageView |
setImageViewResource
public void setImageViewResource (int viewId, int srcId)
Equivalent to calling ImageView.setImageResource(int)
Parameters | |
---|---|
viewId |
int : The id of the view whose drawable should change |
srcId |
int : The new resource id for the drawable |
setImageViewUri
public void setImageViewUri (int viewId, Uri uri)
Equivalent to calling ImageView.setImageURI(Uri)
Parameters | |
---|---|
viewId |
int : The id of the view whose drawable should change |
uri |
Uri : The Uri for the image |
setInt
public void setInt (int viewId, String methodName, int value)
Call a method taking one int on a view in the layout for this RemoteViews.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call. |
value |
int : The value to pass to the method. |
setIntDimen
public void setIntDimen (int viewId, String methodName, float value, int unit)
Call a method taking one int, a size in pixels, on a view in the layout for this RemoteViews. The dimension will be resolved from the specified dimension at the time of inflation.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call.
This value cannot be null . |
value |
float : The value of the dimension. |
unit |
int : The unit in which the value is specified.
Value is TypedValue.COMPLEX_UNIT_PX , TypedValue.COMPLEX_UNIT_DIP , TypedValue.COMPLEX_UNIT_SP , TypedValue.COMPLEX_UNIT_PT , TypedValue.COMPLEX_UNIT_IN , or TypedValue.COMPLEX_UNIT_MM |
setIntDimen
public void setIntDimen (int viewId, String methodName, int dimenResource)
Call a method taking one int, a size in pixels, on a view in the layout for this
RemoteViews.
The dimension will be resolved from the resources at the time the RemoteViews
is
(re-)applied.
Undefined resources will result in an exception, except 0 which will resolve to 0.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call.
This value cannot be null . |
dimenResource |
int : The resource to resolve and pass as argument to the method. |
setIntDimenAttr
public void setIntDimenAttr (int viewId, String methodName, int dimenAttr)
Call a method taking one int, a size in pixels, on a view in the layout for this
RemoteViews.
The dimension will be resolved from the theme attribute at the time the
RemoteViews
is (re-)applied.
Unresolvable attributes will result in an exception, except 0 which will resolve to 0.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call.
This value cannot be null . |
dimenAttr |
int : The attribute to resolve and pass as argument to the method. |
setIntent
public void setIntent (int viewId, String methodName, Intent value)
Call a method taking one Intent on a view in the layout for this RemoteViews.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call. |
value |
Intent : The Intent to pass the method. |
setLabelFor
public void setLabelFor (int viewId, int labeledId)
Equivalent to calling View.setLabelFor(int)
.
Parameters | |
---|---|
viewId |
int : The id of the view whose property to set. |
labeledId |
int : The id of a view for which this view serves as a label. |
setLightBackgroundLayoutId
public void setLightBackgroundLayoutId (int layoutId)
Provides an alternate layout ID, which can be used to inflate this view. This layout will be used by the host when the widgets displayed on a light-background where foreground elements and text can safely draw using a dark color without any additional background protection.
Parameters | |
---|---|
layoutId |
int |
setLong
public void setLong (int viewId, String methodName, long value)
Call a method taking one long on a view in the layout for this RemoteViews.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call. |
value |
long : The value to pass to the method. |
setOnCheckedChangeResponse
public void setOnCheckedChangeResponse (int viewId, RemoteViews.RemoteResponse response)
Equivalent to calling
CompoundButton.setOnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener)
to launch the provided RemoteResponse
.
The intent will be filled with the current checked state of the view at the key
EXTRA_CHECKED
.
The RemoteResponse
will not be launched in response to check changes arising from
setCompoundButtonChecked(int, boolean)
or setRadioGroupChecked(int, int)
usages.
The RemoteResponse
must be created using
RemoteResponse.fromFillInIntent(Intent)
in conjunction with
RemoteViews.setPendingIntentTemplate(int, PendingIntent)
for items inside
collections (eg. ListView
, StackView
etc.).
Otherwise, create the RemoteResponse
using
RemoteResponse.fromPendingIntent(PendingIntent)
.
Parameters | |
---|---|
viewId |
int : The id of the view that will trigger the PendingIntent when checked
state changes. |
response |
RemoteViews.RemoteResponse : The RemoteResponse to send when the checked state changes.
This value cannot be null . |
setOnClickFillInIntent
public void setOnClickFillInIntent (int viewId, Intent fillInIntent)
When using collections (eg. ListView
, StackView
etc.) in widgets, it is very
costly to set PendingIntents on the individual items, and is hence not recommended. Instead
a single PendingIntent template can be set on the collection, see setPendingIntentTemplate(int, android.app.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. The rest
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.
Parameters | |
---|---|
viewId |
int : The id of the view on which to set the fillInIntent |
fillInIntent |
Intent : 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 |
setOnClickPendingIntent
public void setOnClickPendingIntent (int viewId, PendingIntent pendingIntent)
Equivalent to calling
View.setOnClickListener(android.view.View.OnClickListener)
to launch the provided PendingIntent
. The source bounds
(Intent.getSourceBounds()
) of the intent will be set to the bounds of the clicked
view in screen space.
Note that any activity options associated with the mPendingIntent may get overridden
before starting the intent.
When setting the on-click action of items within collections (eg. ListView
,
StackView
etc.), this method will not work. Instead, use setPendingIntentTemplate(int, android.app.PendingIntent)
in conjunction with
RemoteViews.setOnClickFillInIntent(int, Intent)
.
Parameters | |
---|---|
viewId |
int : The id of the view that will trigger the PendingIntent when clicked |
pendingIntent |
PendingIntent : The PendingIntent to send when user clicks |
setOnClickResponse
public void setOnClickResponse (int viewId, RemoteViews.RemoteResponse response)
Equivalent of calling
View.setOnClickListener(android.view.View.OnClickListener)
to launch the provided RemoteResponse
.
Parameters | |
---|---|
viewId |
int : The id of the view that will trigger the RemoteResponse when clicked |
response |
RemoteViews.RemoteResponse : The RemoteResponse to send when user clicks
This value cannot be null . |
setOnStylusHandwritingPendingIntent
public void setOnStylusHandwritingPendingIntent (int viewId, PendingIntent pendingIntent)
Equivalent to calling View.setHandwritingDelegatorCallback(Runnable)
to send the
provided PendingIntent
.
A common use case is a remote view which looks like a text editor but does not actually
support text editing itself, and clicking on the remote view launches an activity containing
an EditText. To support handwriting initiation in this case, this method can be called on the
remote view to configure it as a handwriting delegator, meaning that stylus movement on the
remote view triggers a PendingIntent
and starts handwriting mode for the delegate
EditText. The PendingIntent
is typically the same as the one passed to setOnClickPendingIntent(int, PendingIntent)
which launches the activity containing the EditText. The EditText
should call View.setIsHandwritingDelegate
to set it as a delegate, and also use
View.setAllowedHandwritingDelegatorPackage
or InputMethodManager.HANDWRITING_DELEGATE_FLAG_HOME_DELEGATOR_ALLOWED
if necessary to support delegators from the package displaying the remote view.
Parameters | |
---|---|
viewId |
int : identifier of the view that will trigger the PendingIntent when a
stylus MotionEvent occurs within the view's bounds |
pendingIntent |
PendingIntent : the PendingIntent to send, or null to clear the
handwriting delegation |
setPendingIntentTemplate
public void setPendingIntentTemplate (int viewId, PendingIntent pendingIntentTemplate)
When using collections (eg. ListView
, StackView
etc.) in widgets, it is very
costly to set PendingIntents on the individual items, and is hence not recommended. 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
RemoteViews.setOnClickFillInIntent(int, Intent)
.
Parameters | |
---|---|
viewId |
int : The id of the collection who's children will use this PendingIntent template
when clicked |
pendingIntentTemplate |
PendingIntent : The PendingIntent to be combined with extras specified
by a child of viewId and executed when that child is clicked |
setProgressBar
public 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.
Parameters | |
---|---|
viewId |
int : The id of the ProgressBar to change |
max |
int : The 100% value for the progress bar |
progress |
int : The current value of the progress bar. |
indeterminate |
boolean : True if the progress bar is indeterminate,
false if not. |
setRadioGroupChecked
public void setRadioGroupChecked (int viewId, int checkedId)
Equivalent to calling RadioGroup.check(int)
.
Parameters | |
---|---|
viewId |
int : The id of the view whose property to set. |
checkedId |
int : The unique id of the radio button to select in the group. |
setRelativeScrollPosition
public void setRelativeScrollPosition (int viewId, int offset)
Equivalent to calling ListView.smoothScrollByOffset(int)
.
Parameters | |
---|---|
viewId |
int : The id of the view to change |
offset |
int : Scroll by this adapter position offset |
setRemoteAdapter
public void setRemoteAdapter (int appWidgetId, int viewId, Intent intent)
This method was deprecated
in API level 15.
This method has been deprecated. See
setRemoteAdapter(int, Intent)
Equivalent to calling AbsListView.setRemoteViewsAdapter(Intent)
.
Parameters | |
---|---|
appWidgetId |
int : The id of the app widget which contains the specified view. (This
parameter is ignored in this deprecated method) |
viewId |
int : The id of the AdapterView |
intent |
Intent : The intent of the service which will be
providing data to the RemoteViewsAdapter |
setRemoteAdapter
public void setRemoteAdapter (int viewId, Intent intent)
This method was deprecated
in API level 35.
use
setRemoteAdapter(int, android.widget.RemoteViews.RemoteCollectionItems)
instead
Equivalent to calling AbsListView.setRemoteViewsAdapter(Intent)
.
Can only be used for App Widgets.
Parameters | |
---|---|
viewId |
int : The id of the AdapterView |
intent |
Intent : The intent of the service which will be
providing data to the RemoteViewsAdapter |
setRemoteAdapter
public void setRemoteAdapter (int viewId, RemoteViews.RemoteCollectionItems items)
Creates a simple Adapter for the viewId specified. The viewId must point to an AdapterView,
ie. 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, Bitmap)
). In the case of numerous images, the use of API is still
possible by setting image URIs instead of Bitmaps, see RemoteViews.setImageViewUri
.
This API is supported in the compatibility library for previous API levels, see
RemoteViewsCompat.
Parameters | |
---|---|
viewId |
int : The id of the AdapterView . |
items |
RemoteViews.RemoteCollectionItems : The items to display in the AdapterView .
This value cannot be null . |
setScrollPosition
public void setScrollPosition (int viewId, int position)
Equivalent to calling ListView.smoothScrollToPosition(int)
.
Parameters | |
---|---|
viewId |
int : The id of the view to change |
position |
int : Scroll to this adapter position |
setShort
public void setShort (int viewId, String methodName, short value)
Call a method taking one short on a view in the layout for this RemoteViews.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call. |
value |
short : The value to pass to the method. |
setString
public void setString (int viewId, String methodName, String value)
Call a method taking one String on a view in the layout for this RemoteViews.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call. |
value |
String : The value to pass to the method. |
setTextColor
public void setTextColor (int viewId, int color)
Equivalent to calling TextView.setTextColor(int)
.
Parameters | |
---|---|
viewId |
int : The id of the view whose text color should change |
color |
int : Sets the text color for all the states (normal, selected,
focused) to be this color. |
setTextViewCompoundDrawables
public void setTextViewCompoundDrawables (int viewId, int left, int top, int right, int bottom)
Equivalent to calling
TextView.setCompoundDrawablesWithIntrinsicBounds(int, int, int, int)
.
Parameters | |
---|---|
viewId |
int : The id of the view whose text should change |
left |
int : The id of a drawable to place to the left of the text, or 0 |
top |
int : The id of a drawable to place above the text, or 0 |
right |
int : The id of a drawable to place to the right of the text, or 0 |
bottom |
int : The id of a drawable to place below the text, or 0 |
setTextViewCompoundDrawablesRelative
public void setTextViewCompoundDrawablesRelative (int viewId, int start, int top, int end, int bottom)
Equivalent to calling TextView.setCompoundDrawablesRelativeWithIntrinsicBounds(int, int, int, int)
.
Parameters | |
---|---|
viewId |
int : The id of the view whose text should change |
start |
int : The id of a drawable to place before the text (relative to the
layout direction), or 0 |
top |
int : The id of a drawable to place above the text, or 0 |
end |
int : The id of a drawable to place after the text, or 0 |
bottom |
int : The id of a drawable to place below the text, or 0 |
setTextViewText
public void setTextViewText (int viewId, CharSequence text)
Equivalent to calling TextView.setText(CharSequence)
Parameters | |
---|---|
viewId |
int : The id of the view whose text should change |
text |
CharSequence : The new text for the view |
setTextViewTextSize
public void setTextViewTextSize (int viewId, int units, float size)
Equivalent to calling TextView.setTextSize(int, float)
Parameters | |
---|---|
viewId |
int : The id of the view whose text size should change |
units |
int : The units of size (e.g. COMPLEX_UNIT_SP) |
size |
float : The size of the text |
setUri
public void setUri (int viewId, String methodName, Uri value)
Call a method taking one Uri on a view in the layout for this RemoteViews.
Parameters | |
---|---|
viewId |
int : The id of the view on which to call the method. |
methodName |
String : The name of the method to call. |
value |
Uri : The value to pass to the method. |
setViewLayoutHeight
public void setViewLayoutHeight (int viewId, float height, int units)
Equivalent to setting ViewGroup.LayoutParams.height
except that you may
provide the value in any dimension units.
NOTE: It is recommended to use TypedValue.COMPLEX_UNIT_PX
only for 0,
ViewGroup.LayoutParams.WRAP_CONTENT
, or ViewGroup.LayoutParams.MATCH_PARENT
.
Setting actual sizes in pixels will behave poorly when the RemoteViews object is used on a
display with a different density.
Parameters | |
---|---|
viewId |
int |
height |
float : height of the view in the given units |
units |
int : The unit type of the value e.g. TypedValue.COMPLEX_UNIT_DIP
Value is TypedValue.COMPLEX_UNIT_PX , TypedValue.COMPLEX_UNIT_DIP , TypedValue.COMPLEX_UNIT_SP , TypedValue.COMPLEX_UNIT_PT , TypedValue.COMPLEX_UNIT_IN , or TypedValue.COMPLEX_UNIT_MM |
setViewLayoutHeightAttr
public void setViewLayoutHeightAttr (int viewId, int heightAttr)
Equivalent to setting ViewGroup.LayoutParams.height
with
the value of the given attribute in the current theme.
Parameters | |
---|---|
viewId |
int |
heightAttr |
int : a dimen attribute to read the height from. |
setViewLayoutHeightDimen
public void setViewLayoutHeightDimen (int viewId, int heightDimen)
Equivalent to setting ViewGroup.LayoutParams.height
with
the result of Resources.getDimensionPixelSize(int)
.
Parameters | |
---|---|
viewId |
int |
heightDimen |
int : a dimen resource to read the height from. |
setViewLayoutMargin
public void setViewLayoutMargin (int viewId, int type, float value, int units)
Equivalent to calling MarginLayoutParams.setMarginEnd
.
Only works if the View.getLayoutParams()
supports margins.
NOTE: It is recommended to use TypedValue.COMPLEX_UNIT_PX
only for 0.
Setting margins in pixels will behave poorly when the RemoteViews object is used on a
display with a different density.
Parameters | |
---|---|
viewId |
int : The id of the view to change |
type |
int : The margin being set e.g. MARGIN_END
Value is MARGIN_LEFT , MARGIN_TOP , MARGIN_RIGHT , MARGIN_BOTTOM , MARGIN_START , or MARGIN_END |
value |
float : a value for the margin the given units. |
units |
int : The unit type of the value e.g. TypedValue.COMPLEX_UNIT_DIP
Value is TypedValue.COMPLEX_UNIT_PX , TypedValue.COMPLEX_UNIT_DIP , TypedValue.COMPLEX_UNIT_SP , TypedValue.COMPLEX_UNIT_PT , TypedValue.COMPLEX_UNIT_IN , or TypedValue.COMPLEX_UNIT_MM |
setViewLayoutMarginAttr
public void setViewLayoutMarginAttr (int viewId, int type, int attr)
Equivalent to calling MarginLayoutParams.setMarginEnd
.
Only works if the View.getLayoutParams()
supports margins.
Parameters | |
---|---|
viewId |
int : The id of the view to change |
type |
int : The margin being set e.g. MARGIN_END
Value is MARGIN_LEFT , MARGIN_TOP , MARGIN_RIGHT , MARGIN_BOTTOM , MARGIN_START , or MARGIN_END |
attr |
int : a dimension attribute to apply to the margin, or 0 to clear the margin. |
setViewLayoutMarginDimen
public void setViewLayoutMarginDimen (int viewId, int type, int dimen)
Equivalent to calling MarginLayoutParams.setMarginEnd
.
Only works if the View.getLayoutParams()
supports margins.
Parameters | |
---|---|
viewId |
int : The id of the view to change |
type |
int : The margin being set e.g. MARGIN_END
Value is MARGIN_LEFT , MARGIN_TOP , MARGIN_RIGHT , MARGIN_BOTTOM , MARGIN_START , or MARGIN_END |
dimen |
int : a dimension resource to apply to the margin, or 0 to clear the margin. |
setViewLayoutWidth
public void setViewLayoutWidth (int viewId, float width, int units)
Equivalent to setting ViewGroup.LayoutParams.width
except that you may
provide the value in any dimension units.
NOTE: It is recommended to use TypedValue.COMPLEX_UNIT_PX
only for 0,
ViewGroup.LayoutParams.WRAP_CONTENT
, or ViewGroup.LayoutParams.MATCH_PARENT
.
Setting actual sizes in pixels will behave poorly when the RemoteViews object is used on a
display with a different density.
Parameters | |
---|---|
viewId |
int |
width |
float : Width of the view in the given units |
units |
int : The unit type of the value e.g. TypedValue.COMPLEX_UNIT_DIP
Value is TypedValue.COMPLEX_UNIT_PX , TypedValue.COMPLEX_UNIT_DIP , TypedValue.COMPLEX_UNIT_SP , TypedValue.COMPLEX_UNIT_PT , TypedValue.COMPLEX_UNIT_IN , or TypedValue.COMPLEX_UNIT_MM |
setViewLayoutWidthAttr
public void setViewLayoutWidthAttr (int viewId, int widthAttr)
Equivalent to setting ViewGroup.LayoutParams.width
with
the value of the given attribute in the current theme.
Parameters | |
---|---|
viewId |
int |
widthAttr |
int : the dimension attribute for the view's width |
setViewLayoutWidthDimen
public void setViewLayoutWidthDimen (int viewId, int widthDimen)
Equivalent to setting ViewGroup.LayoutParams.width
with
the result of Resources.getDimensionPixelSize(int)
.
Parameters | |
---|---|
viewId |
int |
widthDimen |
int : the dimension resource for the view's width |
setViewOutlinePreferredRadius
public void setViewOutlinePreferredRadius (int viewId, float radius, int units)
Sets an OutlineProvider on the view whose corner radius is a dimension calculated using
TypedValue.applyDimension(int, float, DisplayMetrics)
.
NOTE: It is recommended to use TypedValue.COMPLEX_UNIT_PX
only for 0.
Setting margins in pixels will behave poorly when the RemoteViews object is used on a
display with a different density.
Parameters | |
---|---|
viewId |
int |
radius |
float |
units |
int : Value is TypedValue.COMPLEX_UNIT_PX , TypedValue.COMPLEX_UNIT_DIP , TypedValue.COMPLEX_UNIT_SP , TypedValue.COMPLEX_UNIT_PT , TypedValue.COMPLEX_UNIT_IN , or TypedValue.COMPLEX_UNIT_MM |
setViewOutlinePreferredRadiusAttr
public void setViewOutlinePreferredRadiusAttr (int viewId, int attrId)
Sets an OutlineProvider on the view whose corner radius is a dimension attribute with
attrId
.
Parameters | |
---|---|
viewId |
int |
attrId |
int |
setViewOutlinePreferredRadiusDimen
public void setViewOutlinePreferredRadiusDimen (int viewId, int resId)
Sets an OutlineProvider on the view whose corner radius is a dimension resource with
resId
.
Parameters | |
---|---|
viewId |
int |
resId |
int |
setViewPadding
public void setViewPadding (int viewId, int left, int top, int right, int bottom)
Equivalent to calling View.setPadding(int, int, int, int)
.
Parameters | |
---|---|
viewId |
int : The id of the view to change |
left |
int : the left padding in pixels
The units of this value are pixels. |
top |
int : the top padding in pixels
The units of this value are pixels. |
right |
int : the right padding in pixels
The units of this value are pixels. |
bottom |
int : the bottom padding in pixels
The units of this value are pixels. |
setViewVisibility
public void setViewVisibility (int viewId, int visibility)
Equivalent to calling View.setVisibility(int)
Parameters | |
---|---|
viewId |
int : The id of the view whose visibility should change |
visibility |
int : The new visibility for the view
Value is View.VISIBLE , View.INVISIBLE , or View.GONE |
showNext
public void showNext (int viewId)
This method was deprecated
in API level 33.
As RemoteViews may be reapplied frequently, it is preferable to call
setDisplayedChild(int, int)
to ensure that the adapter index does not change
unexpectedly.
Equivalent to calling AdapterViewAnimator.showNext()
Parameters | |
---|---|
viewId |
int : The id of the view on which to call AdapterViewAnimator.showNext() |
showPrevious
public void showPrevious (int viewId)
This method was deprecated
in API level 33.
As RemoteViews may be reapplied frequently, it is preferable to call
setDisplayedChild(int, int)
to ensure that the adapter index does not change
unexpectedly.
Equivalent to calling AdapterViewAnimator.showPrevious()
Parameters | |
---|---|
viewId |
int : The id of the view on which to call AdapterViewAnimator.showPrevious() |
writeToParcel
public void writeToParcel (Parcel dest, int flags)
Flatten this object in to a Parcel.
Parameters | |
---|---|
dest |
Parcel : The Parcel in which the object should be written.
This value cannot be null . |
flags |
int : Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE .
Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE , and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-12-18 UTC.
pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier! Saves Data!
--- a PPN by Garber Painting Akron. With Image Size Reduction included!
Fetched URL: http://developer.android.com/reference/android/widget/RemoteViews
Alternative Proxies: