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. ImageView
  2. android 拖动条改变屏幕亮度
  3. Android(安卓)WebView相关属性
  4. Android图片按比例缩放
  5. android:duplicateParentState="true"
  6. android:windowSoftInputMode属性使用
  7. Android(安卓)系统图标
  8. android:windowSoftInputMode属性使用
  9. Android中的AnimationSet使用

随机推荐

  1. 做一个没有视图的零食吧?
  2. Spring Security的permitAll对某些端点不
  3. java i/o输入输出流
  4. JavaScript权威设计--jQuery,Ajax.animat
  5. 如何在命令中传递对象参数?
  6. Java中的两种XML解析技术DOM和SAX
  7. 云星数据---Apache Flink实战系列(精品版
  8. 正在学习C#的新手请教:ASP.NET、HTML5, ja
  9. java 中 数值不超过3万. 用short好 还是i
  10. jbpm在rest API中修改 task Variable