LocaleListCompat
class LocaleListCompat
kotlin.Any | |
↳ | androidx.core.os.LocaleListCompat |
Helper for accessing features in LocaleList
.
Summary
Public methods |
|
---|---|
static LocaleListCompat |
Creates a new instance of |
Boolean | |
static LocaleListCompat |
forLanguageTags(@Nullable list: String?) Generates a new LocaleList with the given language tags. |
Locale! |
Retrieves the |
static LocaleListCompat |
Returns the default locale list, adjusted by moving the default locale to its first position. |
static LocaleListCompat |
The result is guaranteed to include the default Locale returned by Locale. |
static LocaleListCompat |
Retrieve an empty instance of |
Locale? |
getFirstMatch(@NonNull supportedLocales: Array<String!>) Returns the first match in the locale list given an unordered array of supported locales in BCP 47 format. |
Int |
hashCode() |
Int |
Searches this |
Boolean |
isEmpty() Returns whether the |
Int |
size() Returns the number of |
String |
Retrieves a String representation of the language tags in this list. |
String |
toString() |
Any? |
unwrap() Gets the underlying framework object. |
static LocaleListCompat! | |
static LocaleListCompat |
wrap(@NonNull localeList: LocaleList) Creates a new instance of |
Public methods
create
@NonNull static fun create(@NonNull vararg localeList: Locale!): LocaleListCompat
Creates a new instance of LocaleListCompat
from the Locale
array.
forLanguageTags
@NonNull static fun forLanguageTags(@Nullable list: String?): LocaleListCompat
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. |
Return | |
---|---|
LocaleListCompat: A new instance with the Locale items identified by the given tags. |
get
fun get(index: Int): Locale!
Retrieves the Locale
at the specified index.
Parameters | |
---|---|
index |
Int: The position to retrieve. |
Return | |
---|---|
Locale!: The Locale in the given index |
getAdjustedDefault
@NonNull static fun getAdjustedDefault(): LocaleListCompat
Returns the default locale list, adjusted by moving the default locale to its first position.
getDefault
@NonNull static fun getDefault(): LocaleListCompat
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.
getEmptyLocaleList
@NonNull static fun getEmptyLocaleList(): LocaleListCompat
Retrieve an empty instance of LocaleListCompat
.
getFirstMatch
@Nullable fun getFirstMatch(@NonNull supportedLocales: Array<String!>): Locale?
Returns the first match in the locale list given an unordered array of supported locales in BCP 47 format.
Return | |
---|---|
Locale?: The first Locale from this list that appears in the given array, or null if the LocaleListCompat is empty. |
hashCode
fun hashCode(): Int
indexOf
fun indexOf(locale: Locale!): Int
Searches this LocaleListCompat
for the specified Locale
and returns the index of the first occurrence.
Parameters | |
---|---|
locale |
Locale!: The Locale to search for. |
Return | |
---|---|
Int: The index of the first occurrence of the Locale or -1 if the item wasn't found |
isEmpty
fun isEmpty(): Boolean
Returns whether the LocaleListCompat
contains no Locale
items.
Return | |
---|---|
Boolean: true if this LocaleListCompat has no Locale items, false otherwise |
toLanguageTags
@NonNull fun toLanguageTags(): String
Retrieves a String representation of the language tags in this list.
toString
fun toString(): String
unwrap
@Nullable fun unwrap(): Any?
Gets the underlying framework object.
Return | |
---|---|
Any?: an android.os.LocaleList object if API >= 24 , or null if not. |
wrap
@NonNull static fun wrap(@NonNull localeList: LocaleList): LocaleListCompat
Creates a new instance of LocaleListCompat
from the Locale list.