Created
July 29, 2014 10:55
-
-
Save anonymous/2442838dd720972b3476 to your computer and use it in GitHub Desktop.
Template about how ot init custom views.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyCustomView extends View { | |
/** | |
* Constructor intended for programmatic instantiation of view | |
*/ | |
public MyCustomView(Context context) { | |
super(context); | |
initView();// onFinishInflate is not invoked | |
} | |
/** | |
* Invoked by inflater | |
*/ | |
public MyCustomView(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
// initView is invoked in onFinishInflate | |
// if invoke it here, child views won't be found | |
} | |
/** | |
* Invoked by inflater when style is set | |
*/ | |
public MyCustomView(Context context, AttributeSet attrs, int defStyle) { | |
super(context, attrs); | |
// initView is invoked in onFinishInflate | |
// if invoke it here, child views won't be found | |
} | |
@Override | |
public void onFinishInflate() { | |
super.onFinishInflate(); | |
initView(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment