ConstrainedFieldPosition.ConstrainClass(Class) Method

Definition

Sets a constraint on the field class.

[Android.Runtime.Register("constrainClass", "(Ljava/lang/Class;)V", "GetConstrainClass_Ljava_lang_Class_Handler", ApiSince=31)]
public virtual void ConstrainClass (Java.Lang.Class? classConstraint);
[<Android.Runtime.Register("constrainClass", "(Ljava/lang/Class;)V", "GetConstrainClass_Ljava_lang_Class_Handler", ApiSince=31)>]
abstract member ConstrainClass : Java.Lang.Class -> unit
override this.ConstrainClass : Java.Lang.Class -> unit

Parameters

classConstraint
Class

The field class to fix when iterating.

Attributes

Remarks

Sets a constraint on the field class.

When this instance of ConstrainedFieldPosition is passed to FormattedValue#nextPosition, positions are skipped unless the field is an instance of the class constraint, including subclasses.

Any previously set constraints are cleared.

For example, to loop over only the number-related fields:

ConstrainedFieldPosition cfpos;
            cfpos.constrainClass(NumberFormat.Field.class);
            while (fmtval.nextPosition(cfpos)) {
              // handle the number-related field position
            }

Java documentation for android.icu.text.ConstrainedFieldPosition.constrainClass(java.lang.Class<?>).

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