Added in API level 14

SuggestionSpan


open class SuggestionSpan : CharacterStyle, ParcelableSpan
kotlin.Any
   ↳ android.text.style.CharacterStyle
   ↳ android.text.style.SuggestionSpan

Holds suggestion candidates for the text enclosed in this span. When such a span is edited in an EditText, double tapping on the text enclosed in this span will display a popup dialog listing suggestion replacement for that text. The user can then replace the original text by one of the suggestions. These spans should typically be created by the input method to provide correction and alternates for the text.

Summary

Constants
static String

This action is deprecated in android.os.Build.VERSION_CODES#Q.

static Int

Sets this flag if the auto correction is about to be applied to a word/text that the user is typing/composing.

static Int

Sets this flag if the suggestions should be easily accessible with few interactions.

static Int

Sets this flag if the suggestions apply to a grammar error.

static Int

Sets this flag if the suggestions apply to a misspelled word/text.

static Int

static String

This is deprecated in android.os.Build.VERSION_CODES#Q.

static String

This is deprecated in android.os.Build.VERSION_CODES#Q.

static String

This is deprecated in android.os.Build.VERSION_CODES#Q.

Public constructors
SuggestionSpan(context: Context!, suggestions: Array<String!>!, flags: Int)

SuggestionSpan(locale: Locale!, suggestions: Array<String!>!, flags: Int)

SuggestionSpan(context: Context!, locale: Locale!, suggestions: Array<String!>!, flags: Int, notificationTargetClass: Class<*>!)

Public methods
open Int

open Boolean
equals(other: Any?)

Indicates whether some other object is "equal to" this one.

open Int

open String

open Locale?

Returns a well-formed BCP 47 language tag representation of the suggestions, as a Locale object.

open Int

open Array<String!>!

open Int

open Int

open Unit
setFlags(flags: Int)

open Unit

open Unit
writeToParcel(dest: Parcel, flags: Int)

Inherited functions
Properties
static Parcelable.Creator<SuggestionSpan!>

Constants

ACTION_SUGGESTION_PICKED

Added in API level 14
Deprecated in API level 29
static val ACTION_SUGGESTION_PICKED: String

Deprecated: For IMEs to receive this kind of user interaction signals, implement IMEs' own suggestion picker UI instead of relying on SuggestionSpan. To retrieve bounding boxes for each character of the composing text, use android.view.inputmethod.CursorAnchorInfo.

This action is deprecated in android.os.Build.VERSION_CODES#Q.

Value: "android.text.style.SUGGESTION_PICKED"

FLAG_AUTO_CORRECTION

Added in API level 15
static val FLAG_AUTO_CORRECTION: Int

Sets this flag if the auto correction is about to be applied to a word/text that the user is typing/composing. This type of suggestion is rendered differently to indicate the auto correction is happening.

Value: 4

FLAG_EASY_CORRECT

Added in API level 14
static val FLAG_EASY_CORRECT: Int

Sets this flag if the suggestions should be easily accessible with few interactions. This flag should be set for every suggestions that the user is likely to use.

Value: 1

FLAG_GRAMMAR_ERROR

Added in API level 31
static val FLAG_GRAMMAR_ERROR: Int

Sets this flag if the suggestions apply to a grammar error. This type of suggestion is rendered differently to highlight the error.

Value: 8

FLAG_MISSPELLED

Added in API level 14
static val FLAG_MISSPELLED: Int

Sets this flag if the suggestions apply to a misspelled word/text. This type of suggestion is rendered differently to highlight the error.

Value: 2

SUGGESTIONS_MAX_SIZE

Added in API level 14
static val SUGGESTIONS_MAX_SIZE: Int
Value: 5

SUGGESTION_SPAN_PICKED_AFTER

Added in API level 14
Deprecated in API level 29
static val SUGGESTION_SPAN_PICKED_AFTER: String

Deprecated: See ACTION_SUGGESTION_PICKED.

This is deprecated in android.os.Build.VERSION_CODES#Q.

Value: "after"

SUGGESTION_SPAN_PICKED_BEFORE

Added in API level 14
Deprecated in API level 29
static val SUGGESTION_SPAN_PICKED_BEFORE: String

Deprecated: See ACTION_SUGGESTION_PICKED.

This is deprecated in android.os.Build.VERSION_CODES#Q.

Value: "before"

SUGGESTION_SPAN_PICKED_HASHCODE

Added in API level 14
Deprecated in API level 29
static val SUGGESTION_SPAN_PICKED_HASHCODE: String

Deprecated: See ACTION_SUGGESTION_PICKED.

This is deprecated in android.os.Build.VERSION_CODES#Q.

Value: "hashcode"

Public constructors

SuggestionSpan

Added in API level 14
SuggestionSpan(
    context: Context!,
    suggestions: Array<String!>!,
    flags: Int)
Parameters
context Context!: Context for the application
suggestions Array<String!>!: Suggestions for the string under the span
flags Int: Additional flags indicating how this span is handled in TextView

SuggestionSpan

Added in API level 14
SuggestionSpan(
    locale: Locale!,
    suggestions: Array<String!>!,
    flags: Int)
Parameters
locale Locale!: Locale of the suggestions
suggestions Array<String!>!: Suggestions for the string under the span
flags Int: Additional flags indicating how this span is handled in TextView

SuggestionSpan

Added in API level 14
SuggestionSpan(
    context: Context!,
    locale: Locale!,
    suggestions: Array<String!>!,
    flags: Int,
    notificationTargetClass: Class<*>!)
Parameters
context Context!: Context for the application
locale Locale!: locale Locale of the suggestions
suggestions Array<String!>!: Suggestions for the string under the span. Only the first up to SuggestionSpan#SUGGESTIONS_MAX_SIZE will be considered. Null values not permitted.
flags Int: Additional flags indicating how this span is handled in TextView
notificationTargetClass Class<*>!: if not null, this class will get notified when the user selects one of the suggestions. On Android android.os.Build.VERSION_CODES#Q and later this parameter is always ignored.

SuggestionSpan

Added in API level 14
SuggestionSpan(src: Parcel!)

Public methods

describeContents

Added in API level 14
open fun describeContents(): Int
Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

equals

Added in API level 14
open fun equals(other: Any?): Boolean

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj the reference object with which to compare.
o This value may be null.
Return
Boolean true if this object is the same as the obj argument; false otherwise.

getFlags

Added in API level 14
open fun getFlags(): Int

getLocale

Added in API level 14
Deprecated in API level 24
open fun getLocale(): String

Deprecated: use getLocaleObject() instead.

Return
String the locale of the suggestions. An empty string is returned if no locale is specified. This value cannot be null.

getLocaleObject

Added in API level 24
open fun getLocaleObject(): Locale?

Returns a well-formed BCP 47 language tag representation of the suggestions, as a Locale object.

Caveat: The returned object is guaranteed to be a a well-formed BCP 47 language tag representation. For example, this method can return an empty locale rather than returning a malformed data when this object is initialized with an malformed Locale object, e.g. new Locale(" a ", " b c d ", " ".

Return
Locale? the locale of the suggestions. null is returned if no locale is specified.

getSpanTypeId

Added in API level 14
open fun getSpanTypeId(): Int

getSuggestions

Added in API level 14
open fun getSuggestions(): Array<String!>!
Return
Array<String!>! an array of suggestion texts for this span

getUnderlineColor

Added in API level 29
open fun getUnderlineColor(): Int
Return
Int The color of the underline for that span, or 0 if there is no underline

hashCode

Added in API level 14
open fun hashCode(): Int
Return
Int a hash code value for this object.

setFlags

Added in API level 14
open fun setFlags(flags: Int): Unit

updateDrawState

Added in API level 14
open fun updateDrawState(tp: TextPaint!): Unit

writeToParcel

Added in API level 14
open fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit
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_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Properties

CREATOR

Added in API level 14
static val CREATOR: Parcelable.Creator<SuggestionSpan!>