I have a res/layout/main.xml
including these elements and others:
<some.package.MyCustomView android:id="@+id/foo" (some other params) />
<TextView android:id="@+id/boring" (some other params) />
In my Activity's onCreate, I do this:
setContentView(R.layout.main);
(TextView) boring = findViewById(R.id.boring);
// ...find other elements...
MyCustomView foo = (MyCustomView) findViewById(R.id.foo);
if (foo == null) { Log.d(TAG, "epic fail"); }
The other elements are found successfully, but foo
comes back null. MyCustomView has a constructor MyCustomView(Context c, AttributeSet a)
and a Log.d(...)
at the end of that constructor appears successfully in logcat just before the "epic fail".
Why is foo
null?