When I check QuickContactBadge in FrameLayout, I found following code:
public QuickContactBadge(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
TypedArray a =
context.obtainStyledAttributes(attrs,
com.android.internal.R.styleable.QuickContactBadge, defStyle, 0);
mMode = a.getInt(com.android.internal.R.styleable.QuickContactBadge_quickContactWindowSize,
QuickContact.MODE_MEDIUM);
a.recycle();
init();
mBadgeBackground = getBackground();
}
I don’t really catch the meaning of defstyle and 0 parameter in obtainStyledAttributes(). I have looked up reference, but still don’t know what it used for.
The documentation says:
"Can be 0 to not look for defaults." If you set this to 0 then it’s not going to try to grab default values for the style attributes. It does seem a little counter-intuitive, why overload this method if you can just pass in a 0… but I think it is so you can tell it not to look in
defStyleAttrfor defaults but do tell it to look indefStyleResfor defaults, and vice versa.