Layout not being inflated in android custom component
I'm getting a null pointer exception in my custom view (which is derived from a LinearLayout ) because it can't find its child views. Here is the code: public class MyView extends LinearLayout { public MyView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public MyView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } private TextView mText; @Override protected void onFinishInflate() { super.onFinishInflate(); mText = (TextView) findViewById(R.id.text); if (isInEditMode()) { mText.setText("Some example text."); } } } Here is the layout (