Skip to content

Most visited

Recently visited

navigation

ListFormatter

public final class ListFormatter
extends Object

java.lang.Object
   ↳ android.icu.text.ListFormatter


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

Summary

Public methods

String format(Object... items)

Format a list of objects.

String format(Collection<?> items)

Format a collection of objects.

static ListFormatter getInstance(ULocale locale)

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 getInstance()

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

String getPatternForNumItems(int count)

Returns the pattern to use for a particular item count.

Inherited methods

From class java.lang.Object

Public methods

format

added in API level 26
String format (Object... items)

Format a list of objects.

Parameters
items Object: items to format. The toString() method is called on each.

Returns
String items formatted into a string

format

added in API level 26
String format (Collection<?> items)

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

Parameters
items Collection: items to format. The toString() method is called on each.

Returns
String items formatted into a string

getInstance

added in API level 26
ListFormatter getInstance (ULocale locale)

Create a list formatter that is appropriate for a locale.

Parameters
locale ULocale: the locale in question.

Returns
ListFormatter ListFormatter

getInstance

added in API level 26
ListFormatter getInstance (Locale locale)

Create a list formatter that is appropriate for a locale.

Parameters
locale Locale: the locale in question.

Returns
ListFormatter ListFormatter

getInstance

added in API level 26
ListFormatter getInstance ()

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

Returns
ListFormatter ListFormatter

getPatternForNumItems

added in API level 26
String getPatternForNumItems (int count)

Returns the pattern to use for a particular item count.

Parameters
count int: the item count.

Returns
String the pattern with {0}, {1}, {2}, etc. For English, getPatternForNumItems(3) == "{0}, {1}, and {2}"

Throws
IllegalArgumentException when count is 0 or negative.
This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)