API-TypedArray
16lz
2021-01-23
TypedArray | Android Developers
https://developer.android.google.cn/reference/android/content/res/TypedArray.html
简介:Container for an array of values that were retrieved with obtainStyledAttributes(AttributeSet, int[], int, int) or obtainAttributes(AttributeSet, int[]). Be sure to call recycle() when done with them. The indices used to retrieve values from this structure correspond to the positions of the attributes given to obtainStyledAttributes.
翻译过来就是:
- 一个用来检索属性值的容器;
- 使用完之后,必须recycle();
- index下标用来检索属性,相当于属性在obtainStyledAttributes(获取样式属性)中的position.
再来看方法:
返回值 | 方法名 |
---|---|
boolean | getBoolean(int index, boolean defValue) |
int | getColor(int index, int defValue) |
float | getDimension(int index, float defValue) |
Drawable | getDrawable(int index) |
float | getFloat(int index, float defValue) |
int | getInt(int index, int defValue) |
int | getInteger(int index, int defValue) |
String | getString(int index) |
CharSequence | getText(int index) |
其他方法:
返回值 | 方法名 | 解释 |
---|---|---|
ColorStateList | getColorStateList(int index) | |
int | getDimensionPixelOffset(int index, int defValue) | |
int | getDimensionPixelSize(int index, int defValue) | |
float | getFraction(int index, int base, int pbase, float defValue) | |
int | getIndex(int at) | |
int | getIndexCount() | |
int | getLayoutDimension(int index, int defValue) | |
int | getLayoutDimension(int index, String name) | |
String | getNonResourceString(int index) | |
String | getPositionDescription() | |
int | getResourceId(int index, int defValue) | |
Resources | getResources() | |
CharSequence[] g | etTextArray(int index) | |
boolean | getValue(int index, TypedValue outValue) | |
boolean | hasValue(int index) | |
int | length() | |
TypedValue | peekValue(int index) | |
void | recycle() |
更多相关文章
- canvas.drawRoundRect方法,绘制圆角矩形
- android抓log方法
- android 登陆右上角 的关闭按钮的使用方法
- Android AESUtils 工具类与调用方法
- sqlit导入外部数据库查找数据方法
- Android NDK打印log到logcat的方法
- Android获取系统时间的多种方法