Setting/Getting IDs on custom Views on Android
public class CustomView extends ViewGroup {
private View childView;
public LookView(Context context, AttributeSet attrs) {
super(context, attrs);
//Never do it here
//this.childView = this.findViewById(R.id.childView);
}
@Override
protected void onFinishInflate() {
//Do it here :)
this.childView = this.findViewById(R.id.childView);
}
}
Written by Samuel Barbosa
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Android
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#