added in version 26.1.0
belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1

LocaleListCompat

public final class LocaleListCompat
extends Object

java.lang.Object
   ↳ android.support.v4.os.LocaleListCompat


Helper for accessing features in LocaleList.

Summary

Public methods

static LocaleListCompat create(Locale... localeList)

Creates a new instance of LocaleListCompat from the Locale array.

boolean equals(Object other)
static LocaleListCompat forLanguageTags(String list)

Generates a new LocaleList with the given language tags.

Locale get(int index)

Retrieves the Locale at the specified index.

static LocaleListCompat getAdjustedDefault()

Returns the default locale list, adjusted by moving the default locale to its first position.

static LocaleListCompat getDefault()

The result is guaranteed to include the default Locale returned by Locale.getDefault(), but not necessarily at the top of the list.

static LocaleListCompat getEmptyLocaleList()

Retrieve an empty instance of LocaleList.

Locale getFirstMatch(String[] supportedLocales)

Returns the first match in the locale list given an unordered array of supported locales in BCP 47 format.

int hashCode()
int indexOf(Locale locale)

Searches this LocaleListCompat for the specified Locale and returns the index of the first occurrence.

boolean isEmpty()

Returns whether the LocaleListCompat contains no Locale items.

int size()

Returns the number of Locale items in this LocaleListCompat.

String toLanguageTags()

Retrieves a String representation of the language tags in this list.

String toString()
Object unwrap()

Gets the underlying framework object.

static LocaleListCompat wrap(Object object)

Creates a new instance of LocaleListCompat from the Locale list.

Inherited methods

From class java.lang.Object

Public methods

create

added in version 26.1.0
LocaleListCompat create (Locale... localeList)

Creates a new instance of LocaleListCompat from the Locale array.

Parameters
localeList Locale

Returns
LocaleListCompat

equals

boolean equals (Object other)

Parameters
other Object

Returns
boolean

forLanguageTags

added in version 26.1.0
LocaleListCompat forLanguageTags (String list)

Generates a new LocaleList with the given language tags.

Note that for API < 24 only the first language tag will be used.

Parameters
list String: The language tags to be included as a single String separated by commas.

Returns
LocaleListCompat A new instance with the Locale items identified by the given tags.

get

added in version 26.1.0
Locale get (int index)

Retrieves the Locale at the specified index.

Parameters
index int: The position to retrieve.

Returns
Locale The Locale in the given index

getAdjustedDefault

added in version 26.1.0
LocaleListCompat getAdjustedDefault ()

Returns the default locale list, adjusted by moving the default locale to its first position.

Returns
LocaleListCompat

getDefault

added in version 26.1.0
LocaleListCompat getDefault ()

The result is guaranteed to include the default Locale returned by Locale.getDefault(), but not necessarily at the top of the list. The default locale not being at the top of the list is an indication that the system has set the default locale to one of the user's other preferred locales, having concluded that the primary preference is not supported but a secondary preference is.

Note that for API >= 24 the default LocaleList would change if Locale.setDefault() is called. This method takes that into account by always checking the output of Locale.getDefault() and recalculating the default LocaleList if needed.

Returns
LocaleListCompat

getEmptyLocaleList

added in version 26.1.0
LocaleListCompat getEmptyLocaleList ()

Retrieve an empty instance of LocaleList.

Returns
LocaleListCompat

getFirstMatch

added in version 26.1.0
Locale getFirstMatch (String[] supportedLocales)

Returns the first match in the locale list given an unordered array of supported locales in BCP 47 format.

Parameters
supportedLocales String

Returns
Locale The first Locale from this list that appears in the given array, or null if the LocaleListCompat is empty.

hashCode

int hashCode ()

Returns
int

indexOf

added in version 26.1.0
int indexOf (Locale locale)

Searches this LocaleListCompat for the specified Locale and returns the index of the first occurrence.

Parameters
locale Locale: The Locale to search for.

Returns
int The index of the first occurrence of the Locale or -1 if the item wasn't found

Value is -1 or greater.

isEmpty

added in version 26.1.0
boolean isEmpty ()

Returns whether the LocaleListCompat contains no Locale items.

Returns
boolean true if this LocaleListCompat has no Locale items, false otherwise

size

added in version 26.1.0
int size ()

Returns the number of Locale items in this LocaleListCompat.

Returns
int

toLanguageTags

added in version 26.1.0
String toLanguageTags ()

Retrieves a String representation of the language tags in this list.

Returns
String

toString

String toString ()

Returns
String

unwrap

added in version 26.1.0
Object unwrap ()

Gets the underlying framework object.

Returns
Object an android.os.LocaleList object if API >= 24 , or Locale if not.

wrap

added in version 26.1.0
LocaleListCompat wrap (Object object)

Creates a new instance of LocaleListCompat from the Locale list.

Parameters
object Object

Returns
LocaleListCompat