LocaleListCompat
public
final
class
LocaleListCompat
extends Object
java.lang.Object | |
↳ | androidx.core.os.LocaleListCompat |
Helper for accessing features in LocaleList
.
Summary
Public methods | |
---|---|
static
LocaleListCompat
|
create(Locale... localeList)
Creates a new instance of |
boolean
|
equals(Object other)
|
static
LocaleListCompat
|
forLanguageTags(String list)
Generates a new LocaleList with the given language tags. |
Locale
|
get(int index)
Retrieves the |
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 |
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 |
boolean
|
isEmpty()
Returns whether the |
int
|
size()
Returns the number of |
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 localeList)
This method is deprecated.
Use |
static
LocaleListCompat
|
wrap(LocaleList localeList)
Creates a new instance of |
Inherited methods | |
---|---|
Public methods
create
public static LocaleListCompat create (Locale... localeList)
Creates a new instance of LocaleListCompat
from the Locale
array.
Parameters | |
---|---|
localeList |
Locale |
Returns | |
---|---|
LocaleListCompat |
equals
public boolean equals (Object other)
Parameters | |
---|---|
other |
Object |
Returns | |
---|---|
boolean |
forLanguageTags
public static 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
public 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
public static LocaleListCompat getAdjustedDefault ()
Returns the default locale list, adjusted by moving the default locale to its first position.
Returns | |
---|---|
LocaleListCompat |
getDefault
public 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. 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
public static LocaleListCompat getEmptyLocaleList ()
Retrieve an empty instance of LocaleListCompat
.
Returns | |
---|---|
LocaleListCompat |
getFirstMatch
public 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
public int hashCode ()
Returns | |
---|---|
int |
indexOf
public 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
public boolean isEmpty ()
Returns whether the LocaleListCompat
contains no Locale
items.
Returns | |
---|---|
boolean |
true if this LocaleListCompat has no Locale items,
false otherwise
|
toLanguageTags
public String toLanguageTags ()
Retrieves a String representation of the language tags in this list.
Returns | |
---|---|
String |
toString
public String toString ()
Returns | |
---|---|
String |
unwrap
public Object unwrap ()
Gets the underlying framework object.
Returns | |
---|---|
Object |
an android.os.LocaleList object if API >= 24 , or null if not.
|
wrap
public static LocaleListCompat wrap (Object localeList)
This method is deprecated.
Use wrap(LocaleList)
Parameters | |
---|---|
localeList |
Object |
Returns | |
---|---|
LocaleListCompat |
wrap
public static LocaleListCompat wrap (LocaleList localeList)
Creates a new instance of LocaleListCompat
from the Locale list.
Parameters | |
---|---|
localeList |
LocaleList |
Returns | |
---|---|
LocaleListCompat |