Added in API level 26

ListFormatter

class ListFormatter
kotlin.Any
   ↳ android.icu.text.ListFormatter

Immutable class for formatting a list, using data from CLDR (or supplied separately). The class is not subclassable.

Summary

Nested classes

An immutable class containing the result of a list formatting operation.

Type of meaning expressed by the list.

Verbosity level of the list patterns.

Public methods
String!
format(vararg items: Any!)

Format a list of objects.

String!

Format a collection of objects.

ListFormatter.FormattedList!
formatToValue(vararg items: Any!)

Format a list of objects to a FormattedList.

ListFormatter.FormattedList!

Format a collection of objects to a FormattedList.

static ListFormatter!

Create a list formatter that is appropriate for a locale.

static ListFormatter!

Create a list formatter that is appropriate for a locale.

static ListFormatter!
getInstance(locale: ULocale!)

Create a list formatter that is appropriate for a locale.

static ListFormatter!
getInstance(locale: Locale!)

Create a list formatter that is appropriate for a locale.

static ListFormatter!

Create a list formatter that is appropriate for the default FORMAT locale.

String!

Returns the pattern to use for a particular item count.

Public methods

format

Added in API level 26
fun format(vararg items: Any!): String!

Format a list of objects.

Parameters
items Any!: items to format. The toString() method is called on each.
Return
String! items formatted into a string

format

Added in API level 26
fun format(items: MutableCollection<*>!): String!

Format a collection of objects. The toString() method is called on each.

Parameters
items MutableCollection<*>!: items to format. The toString() method is called on each.
Return
String! items formatted into a string

formatToValue

Added in API level 33
fun formatToValue(vararg items: Any!): ListFormatter.FormattedList!

Format a list of objects to a FormattedList. You can access the offsets of each element from the FormattedList.

Parameters
items Any!: items to format. The toString() method is called on each.
Return
ListFormatter.FormattedList! items formatted into a FormattedList

formatToValue

Added in API level 33
fun formatToValue(items: MutableCollection<*>!): ListFormatter.FormattedList!

Format a collection of objects to a FormattedList. You can access the offsets of each element from the FormattedList.

Parameters
items MutableCollection<*>!: items to format. The toString() method is called on each.
Return
ListFormatter.FormattedList! items formatted into a FormattedList

getInstance

Added in API level 33
static fun getInstance(
    locale: ULocale!,
    type: ListFormatter.Type!,
    width: ListFormatter.Width!
): ListFormatter!

Create a list formatter that is appropriate for a locale.

Parameters
locale ULocale!: the locale in question.
Return
ListFormatter! ListFormatter

getInstance

Added in API level 33
static fun getInstance(
    locale: Locale!,
    type: ListFormatter.Type!,
    width: ListFormatter.Width!
): ListFormatter!

Create a list formatter that is appropriate for a locale.

Parameters
locale Locale!: the locale in question.
Return
ListFormatter! ListFormatter

getInstance

Added in API level 26
static fun getInstance(locale: ULocale!): ListFormatter!

Create a list formatter that is appropriate for a locale.

Parameters
locale ULocale!: the locale in question.
Return
ListFormatter! ListFormatter

getInstance

Added in API level 26
static fun getInstance(locale: Locale!): ListFormatter!

Create a list formatter that is appropriate for a locale.

Parameters
locale Locale!: the locale in question.
Return
ListFormatter! ListFormatter

getInstance

Added in API level 26
static fun getInstance(): ListFormatter!

Create a list formatter that is appropriate for the default FORMAT locale.

Return
ListFormatter! ListFormatter

getPatternForNumItems

Added in API level 26
fun getPatternForNumItems(count: Int): String!

Returns the pattern to use for a particular item count.

Parameters
count Int: the item count.
Return
String! the pattern with {0}, {1}, {2}, etc. For English, getPatternForNumItems(3) == "{0}, {1}, and {2}"
Exceptions
java.lang.IllegalArgumentException when count is 0 or negative.