RemoteViews | API reference | Android Developers (original) (raw)
public class RemoteViews
extends [Object](/reference/java/lang/Object)
implements[LayoutInflater.Filter](/reference/android/view/LayoutInflater.Filter), [Parcelable](/reference/android/os/Parcelable)
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](/reference/android/widget/AdapterViewFlipper)
[FrameLayout](/reference/android/widget/FrameLayout)
[GridLayout](/reference/android/widget/GridLayout)
[GridView](/reference/android/widget/GridView)
[LinearLayout](/reference/android/widget/LinearLayout)
[ListView](/reference/android/widget/ListView)
[RelativeLayout](/reference/android/widget/RelativeLayout)
[StackView](/reference/android/widget/StackView)
[ViewFlipper](/reference/android/widget/ViewFlipper)
And the following widgets:
[AnalogClock](/reference/android/widget/AnalogClock)
[Button](/reference/android/widget/Button)
[Chronometer](/reference/android/widget/Chronometer)
[ImageButton](/reference/android/widget/ImageButton)
[ImageView](/reference/android/widget/ImageView)
[ProgressBar](/reference/android/widget/ProgressBar)
[TextClock](/reference/android/widget/TextClock)
[TextView](/reference/android/widget/TextView)
As of API 31, the following widgets and layouts may also be used:
[CheckBox](/reference/android/widget/CheckBox)
[RadioButton](/reference/android/widget/RadioButton)
[RadioGroup](/reference/android/widget/RadioGroup)
[Switch](/reference/android/widget/Switch)
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 byRemoteViews.setViewOutlinePreferredRadius(int, float, int). |
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 |
---|
From interfaceandroid.os.Parcelable int CONTENTS_FILE_DESCRIPTOR Descriptor bit used with describeContents(): indicates that the Parcelable object's flattened representation includes a file descriptor. int PARCELABLE_WRITE_RETURN_VALUE Flag for use with writeToParcel(Parcel, int): the object being written is a return value, that is the result of a function such as "Parcelable someFunction()", "void someFunction(out Parcelable)", or "void someFunction(inout Parcelable)". |
Fields | |
---|---|
public static finalCreator<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 DrawInstructions, which serves as an alternative to XML layout. |
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 ViewGroup.addView(View) after inflating the givenRemoteViews. |
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. |
RemoteViews | clone() This method was deprecated in API level 28. use RemoteViews(android.widget.RemoteViews) instead. |
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 usingRemoteViews.RemoteViews(String, int, int). |
boolean | onLoadClass(Class 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. |
void | reapply(Context context, View v) Applies all of the actions to the provided view. |
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 | 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 Chronometer.setBase,Chronometer.setFormat, and Chronometer.start() orChronometer.stop(). |
void | setChronometerCountDown(int viewId, boolean isCountDown) Equivalent to calling Chronometer.setCountDown on the chronometer with the given viewId. |
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 CompoundButton.setChecked(boolean). |
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 | setEmptyView(int viewId, int emptyViewId) Equivalent to calling AdapterView.setEmptyView(View) |
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 ImageView.setImageBitmap(Bitmap) |
void | setImageViewIcon(int viewId, Icon icon) Equivalent to calling ImageView.setImageIcon(Icon) |
void | setImageViewResource(int viewId, int srcId) Equivalent to calling ImageView.setImageResource(int) |
void | setImageViewUri(int viewId, Uri uri) Equivalent to calling ImageView.setImageURI(Uri) |
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 View.setLabelFor(int). |
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 callingCompoundButton.setOnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) to launch the provided RemoteResponse. |
void | setOnClickFillInIntent(int viewId, Intent fillInIntent) When using collections (eg. |
void | setOnClickPendingIntent(int viewId, PendingIntent pendingIntent) Equivalent to callingView.setOnClickListener(android.view.View.OnClickListener) to launch the provided PendingIntent. |
void | setOnClickResponse(int viewId, RemoteViews.RemoteResponse response) Equivalent of callingView.setOnClickListener(android.view.View.OnClickListener) to launch the provided RemoteResponse. |
void | setOnStylusHandwritingPendingIntent(int viewId, PendingIntent pendingIntent) Equivalent to calling View.setHandwritingDelegatorCallback(Runnable) to send the provided PendingIntent. |
void | setPendingIntentTemplate(int viewId, PendingIntent pendingIntentTemplate) When using collections (eg. |
void | setProgressBar(int viewId, int max, int progress, boolean indeterminate) Equivalent to calling ProgressBar.setMax,ProgressBar.setProgress, andProgressBar.setIndeterminate If indeterminate is true, then the values for max and progress are ignored. |
void | setRadioGroupChecked(int viewId, int checkedId) Equivalent to calling RadioGroup.check(int). |
void | setRelativeScrollPosition(int viewId, int offset) Equivalent to calling ListView.smoothScrollByOffset(int). |
void | setRemoteAdapter(int appWidgetId, int viewId, Intent intent) This method was deprecated in API level 15. This method has been deprecated. SeesetRemoteAdapter(int, Intent) |
void | setRemoteAdapter(int viewId, Intent intent) This method was deprecated in API level 35. usesetRemoteAdapter(int, android.widget.RemoteViews.RemoteCollectionItems) instead |
void | setRemoteAdapter(int viewId, RemoteViews.RemoteCollectionItems items) Creates a simple Adapter for the viewId specified. |
void | setScrollPosition(int viewId, int position) Equivalent to calling ListView.smoothScrollToPosition(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, int color) Equivalent to calling TextView.setTextColor(int). |
void | setTextViewCompoundDrawables(int viewId, int left, int top, int right, int bottom) Equivalent to callingTextView.setCompoundDrawablesWithIntrinsicBounds(int, int, int, int). |
void | setTextViewCompoundDrawablesRelative(int viewId, int start, int top, int end, int bottom) Equivalent to calling TextView.setCompoundDrawablesRelativeWithIntrinsicBounds(int, int, int, int). |
void | setTextViewText(int viewId, CharSequence text) Equivalent to calling TextView.setText(CharSequence) |
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 | setViewLayoutHeight(int viewId, float height, int units) Equivalent to setting ViewGroup.LayoutParams.height except that you may provide the value in any dimension units. |
void | setViewLayoutHeightAttr(int viewId, int heightAttr) Equivalent to setting ViewGroup.LayoutParams.height with the value of the given attribute in the current theme. |
void | setViewLayoutHeightDimen(int viewId, int heightDimen) Equivalent to setting ViewGroup.LayoutParams.height with the result of Resources.getDimensionPixelSize(int). |
void | setViewLayoutMargin(int viewId, int type, float value, int units) Equivalent to calling MarginLayoutParams.setMarginEnd. |
void | setViewLayoutMarginAttr(int viewId, int type, int attr) Equivalent to calling MarginLayoutParams.setMarginEnd. |
void | setViewLayoutMarginDimen(int viewId, int type, int dimen) Equivalent to calling MarginLayoutParams.setMarginEnd. |
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. |
void | setViewLayoutWidthAttr(int viewId, int widthAttr) Equivalent to setting ViewGroup.LayoutParams.width with the value of the given attribute in the current theme. |
void | setViewLayoutWidthDimen(int viewId, int widthDimen) Equivalent to setting ViewGroup.LayoutParams.width with the result of Resources.getDimensionPixelSize(int). |
void | setViewOutlinePreferredRadius(int viewId, float radius, int units) Sets an OutlineProvider on the view whose corner radius is a dimension calculated usingTypedValue.applyDimension(int, float, DisplayMetrics). |
void | setViewOutlinePreferredRadiusAttr(int viewId, int attrId) Sets an OutlineProvider on the view whose corner radius is a dimension attribute withattrId. |
void | setViewOutlinePreferredRadiusDimen(int viewId, int resId) Sets an OutlineProvider on the view whose corner radius is a dimension resource withresId. |
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(int) |
void | showNext(int viewId) This method was deprecated in API level 33. As RemoteViews may be reapplied frequently, it is preferable to callsetDisplayedChild(int, int) to ensure that the adapter index does not change unexpectedly. |
void | showPrevious(int viewId) This method was deprecated in API level 33. As RemoteViews may be reapplied frequently, it is preferable to callsetDisplayedChild(int, int) to ensure that the adapter index does not change unexpectedly. |
void | writeToParcel(Parcel dest, int flags) Flatten this object in to a Parcel. |
Inherited methods |
---|
From class java.lang.Object Object clone() Creates and returns a copy of this object. boolean equals(Object obj) Indicates whether some other object is "equal to" this one. void finalize() Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. finalClass<?> getClass() Returns the runtime class of this Object. int hashCode() Returns a hash code value for the object. final void notify() Wakes up a single thread that is waiting on this object's monitor. final void notifyAll() Wakes up all threads that are waiting on this object's monitor. String toString() Returns a string representation of the object. final void wait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. final void wait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. final void wait() Causes the current thread to wait until it is awakened, typically by being notified or interrupted. |
From interface android.view.LayoutInflater.Filter abstract boolean onLoadClass(Class clazz) Hook to allow clients of the LayoutInflater to restrict the set of Views that are allowed to be inflated. |
From interface android.os.Parcelable abstract int describeContents() Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. abstract void writeToParcel(Parcel dest, int flags) Flatten this object in to a Parcel. |
Constants
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"
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](/reference/android/widget/RemoteViews.DrawInstructions)
, which serves as an alternative to XML layout. [DrawInstructions](/reference/android/widget/RemoteViews.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](/reference/android/widget/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)](/reference/android/view/ViewGroup#addView%28android.view.View%29)
after inflating the given[RemoteViews](/reference/android/widget/RemoteViews)
. If the [RemoteViews](/reference/android/widget/RemoteViews)
may be re-inflated or updated,[removeAllViews(int)](/reference/android/widget/RemoteViews#removeAllViews%28int%29)
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)](/reference/android/widget/RemoteViews#RemoteViews%28java.lang.String,%20int,%20int%29)
). 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. |
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 |
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)](/reference/android/os/Parcelable#writeToParcel%28android.os.Parcel,%20int%29)
, the return value of this method must include the[CONTENTS_FILE_DESCRIPTOR](/reference/android/os/Parcelable#CONTENTS%5FFILE%5FDESCRIPTOR)
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. |
onLoadClass
public boolean onLoadClass (Class clazz)
This method is deprecated.
Used by system to enforce safe inflation of [RemoteViews](/reference/android/widget/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 |
removeAllViews
public void removeAllViews (int viewId)
Equivalent to calling [ViewGroup.removeAllViews()](/reference/android/view/ViewGroup#removeAllViews%28%29)
.
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)](/reference/android/view/View#setAccessibilityTraversalAfter%28int%29)
.
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)](/reference/android/view/View#setAccessibilityTraversalBefore%28int%29)
.
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](/reference/android/widget/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](/reference/android/widget/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. |
setChronometerCountDown
public void setChronometerCountDown (int viewId, boolean isCountDown)
Equivalent to calling [Chronometer.setCountDown](/reference/android/widget/Chronometer#setCountDown%28boolean%29)
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](/reference/android/widget/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](/reference/android/widget/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 toConfiguration.UI_MODE_NIGHT_NO |
night | int: The value to pass to the method when the view's configuration is set toConfiguration.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 toConfiguration.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 toConfiguration.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](/reference/android/widget/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](/reference/android/widget/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)](/reference/android/widget/CompoundButton#setChecked%28boolean%29)
.
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. |
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)](/reference/android/widget/AdapterView#setEmptyView%28android.view.View%29)
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](/reference/android/widget/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](/reference/android/widget/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](/reference/android/widget/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 toConfiguration.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 toConfiguration.UI_MODE_NIGHT_YES This value may be null. |
setImageViewBitmap
public void setImageViewBitmap (int viewId, Bitmap bitmap)
Equivalent to calling [ImageView.setImageBitmap(Bitmap)](/reference/android/widget/ImageView#setImageBitmap%28android.graphics.Bitmap%29)
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)](/reference/android/widget/ImageView#setImageIcon%28android.graphics.drawable.Icon%29)
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)](/reference/android/widget/ImageView#setImageResource%28int%29)
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)](/reference/android/widget/ImageView#setImageURI%28android.net.Uri%29)
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](/reference/android/widget/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](/reference/android/widget/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)](/reference/android/view/View#setLabelFor%28int%29)
.
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. |
setOnClickFillInIntent
public void setOnClickFillInIntent (int viewId, Intent fillInIntent)
When using collections (eg. [ListView](/reference/android/widget/ListView)
, [StackView](/reference/android/widget/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)](/reference/android/widget/RemoteViews#setPendingIntentTemplate%28int,%20android.app.PendingIntent%29)
, 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)](/reference/android/content/Intent#fillIn%28android.content.Intent,%20int%29)
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 |
setPendingIntentTemplate
public void setPendingIntentTemplate (int viewId, PendingIntent pendingIntentTemplate)
When using collections (eg. [ListView](/reference/android/widget/ListView)
, [StackView](/reference/android/widget/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)](/reference/android/widget/RemoteViews#setOnClickFillInIntent%28int,%20android.content.Intent%29)
.
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](/reference/android/widget/ProgressBar#setMax%28int%29)
,[ProgressBar.setProgress](/reference/android/widget/ProgressBar#setProgress%28int%29)
, and[ProgressBar.setIndeterminate](/reference/android/widget/ProgressBar#setIndeterminate%28boolean%29)
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)](/reference/android/widget/RadioGroup#check%28int%29)
.
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)](/reference/android/widget/ListView#smoothScrollByOffset%28int%29)
.
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)](/reference/android/widget/RemoteViews#setRemoteAdapter%28int,%20android.content.Intent%29)
Equivalent to calling [AbsListView.setRemoteViewsAdapter(Intent)](/reference/android/widget/AbsListView#setRemoteViewsAdapter%28android.content.Intent%29)
.
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, RemoteViews.RemoteCollectionItems items)
Creates a simple Adapter for the viewId specified. The viewId must point to an AdapterView, ie. [ListView](/reference/android/widget/ListView)
, [GridView](/reference/android/widget/GridView)
, [StackView](/reference/android/widget/StackView)
or [AdapterViewAnimator](/reference/android/widget/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)](/reference/android/widget/RemoteViews#setImageViewBitmap%28int,%20android.graphics.Bitmap%29)
). In the case of numerous images, the use of API is still possible by setting image URIs instead of Bitmaps, see [RemoteViews.setImageViewUri](/reference/android/widget/RemoteViews#setImageViewUri%28int,%20android.net.Uri%29)
. 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)](/reference/android/widget/ListView#smoothScrollToPosition%28int%29)
.
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)](/reference/android/widget/TextView#setTextColor%28int%29)
.
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)](/reference/android/widget/TextView#setCompoundDrawablesWithIntrinsicBounds%28int,%20int,%20int,%20int%29)
.
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)](/reference/android/widget/TextView#setCompoundDrawablesRelativeWithIntrinsicBounds%28int,%20int,%20int,%20int%29)
.
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)](/reference/android/widget/TextView#setText%28java.lang.CharSequence%29)
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)](/reference/android/widget/TextView#setTextSize%28int,%20float%29)
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. |
setViewLayoutHeightAttr
public void setViewLayoutHeightAttr (int viewId, int heightAttr)
Equivalent to setting [ViewGroup.LayoutParams.height](/reference/android/view/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. |
setViewLayoutMargin
public void setViewLayoutMargin (int viewId, int type, float value, int units)
Equivalent to calling [MarginLayoutParams.setMarginEnd](/reference/android/view/ViewGroup.MarginLayoutParams#setMarginEnd%28int%29)
. Only works if the [View.getLayoutParams()](/reference/android/view/View#getLayoutParams%28%29)
supports margins.
NOTE: It is recommended to use [TypedValue.COMPLEX_UNIT_PX](/reference/android/util/TypedValue#COMPLEX%5FUNIT%5FPX)
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 |
setViewLayoutWidthAttr
public void setViewLayoutWidthAttr (int viewId, int widthAttr)
Equivalent to setting [ViewGroup.LayoutParams.width](/reference/android/view/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 |
setViewOutlinePreferredRadiusAttr
public void setViewOutlinePreferredRadiusAttr (int viewId, int attrId)
Sets an OutlineProvider on the view whose corner radius is a dimension attribute withattrId
.
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 withresId
.
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)](/reference/android/view/View#setPadding%28int,%20int,%20int,%20int%29)
.
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)](/reference/android/view/View#setVisibility%28int%29)
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 |
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 |