Skip to content

Instantly share code, notes, and snippets.

@julianshen
Last active December 19, 2015 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save julianshen/5869376 to your computer and use it in GitHub Desktop.
Save julianshen/5869376 to your computer and use it in GitHub Desktop.
init of SimpleCellLayout
public SimpleCellLayout(Context context, AttributeSet attrs) {
super(context, attrs);
initFromAttributes(context, attrs);
}
public SimpleCellLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
initFromAttributes(context, attrs);
}
private void initFromAttributes(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SimpleCellLayout);
for (int i = 0; i < a.getIndexCount(); i++) {
int attr = a.getIndex(i);
switch (attr) {
case R.styleable.SimpleCellLayout_col:
mColCount = a.getInt(attr, mColCount);
break;
case R.styleable.SimpleCellLayout_row:
mRowCount = a.getInt(attr, mRowCount);
break;
case R.styleable.SimpleCellLayout_gapsize:
mGap = a.getDimensionPixelSize(attr, mGap);
break;
}
}
a.recycle();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment