@ThreadSafe public final class ResourceUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
getBoolean(Context context,
String resourceName)
Returns a resource from a string name, rather than an integer ID.
|
static int |
getPositionForIdInArray(Context context,
int arrayId,
int elementId)
Gets the first position of an element in a typed array.
|
static int |
getResourceIdForPositionInArray(Context context,
int arrayId,
int position)
Gets the resource ID of an element in a typed array.
|
public static int getPositionForIdInArray(Context context, @ArrayRes int arrayId, @AnyRes int elementId)
context - Application context.arrayId - resource ID of the array.elementId - resource ID of the element in the array to find. If this id is repeated,
only
position of the first instance will be returned.elementId in the array.NoSuchElementException - if elementId is not in the array.public static int getResourceIdForPositionInArray(Context context, @ArrayRes int arrayId, int position)
context - Application context.arrayId - resource ID of the array.position - position in the array to retrieve.position.IndexOutOfBoundsException - if position is not in the array.