I may be misunderstanding how
and
work, but according to Simple example of
I've solved this by adding ViewStub entries into the layout xml of the parent, and - depending on the type of subclass - inflating the correct stub.
http://developer.android.com/reference/android/view/ViewStub.html
ViewStub is sort of lazy loading a view, so if you never call inflate() on it or never make it visible it won't be added to the layout hierarchy.