private void init(AttributeSet attrs) {
// 数组必须升序
TypedArray typedArray = getContext().obtainStyledAttributes(attrs,
new int[] {android.R.attr.textColor, android.R.attr.background});
textColorId = typedArray.getResourceId(0, -1);
bgId = typedArray.getResourceId(1, -1);
typedArray.recycle();
}
注意啊,里面传的数组一定要升序