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()

更多相关文章

  1. canvas.drawRoundRect方法,绘制圆角矩形
  2. android抓log方法
  3. android 登陆右上角 的关闭按钮的使用方法
  4. Android AESUtils 工具类与调用方法
  5. sqlit导入外部数据库查找数据方法
  6. Android NDK打印log到logcat的方法
  7. Android获取系统时间的多种方法

随机推荐

  1. 什么是守护线程?
  2. 为什么要用并发编程?
  3. Java 中的 volatile 关键字
  4. 线程包括哪些状态?状态之间是如何转变的?
  5. 什么是并发编程?
  6. Java 中的锁
  7. 程序员专业被娃溜...
  8. 讲给前端的正则表达式(2):写出更优雅、更
  9. 什么是线程池?
  10. Java 中的锁如何使用?有什么注意事项?