Android Guides | Samples

Android.Views.View.SetTag Method

Sets a tag associated with this view and a key.

Syntax

[Android.Runtime.Register("setTag", "(ILjava/lang/Object;)V", "GetSetTag_ILjava_lang_Object_Handler")]
public virtual void SetTag (int key, Object tag)

See Also

Parameters

key
The key identifying the tag
tag
An Object to tag the view with

Exceptions

TypeReason
IllegalArgumentExceptionIf 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.

[Android Documentation]

Requirements

Namespace: Android.Views
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 4