View.SetTag(Int32, Object) Method

Definition

Sets a tag associated with this view and a key.

[Android.Runtime.Register("setTag", "(ILjava/lang/Object;)V", "GetSetTag_ILjava_lang_Object_Handler")]
public virtual void SetTag (int key, Java.Lang.Object? tag);
[<Android.Runtime.Register("setTag", "(ILjava/lang/Object;)V", "GetSetTag_ILjava_lang_Object_Handler")>]
abstract member SetTag : int * Java.Lang.Object -> unit
override this.SetTag : int * Java.Lang.Object -> unit

Parameters

key
Int32

The key identifying the tag

tag
Object

An Object to tag the view with

Attributes

Exceptions

If they specified key is not valid

Remarks

Sets a tag associated with this view and a key. A tag can be used to mark a view in its hierarchy and does not have to be unique within the hierarchy. Tags can also be used to store data within a view without resorting to another data structure.

The specified key should be an id declared in the resources of the application to ensure it is unique (see the ID resource type). Keys identified as belonging to the Android framework or not associated with any package will cause an IllegalArgumentException to be thrown.

Java documentation for android.view.View.setTag(int, java.lang.Object).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

See also