I have a FragmentActivity with this layout:
FragmentActivity
The RelativeLayout (i.e. the ViewParent) should have a resource Id defined in the layout file (for example, android:id=@+id/myParentViewId). If you don't do that, the call to getId will return null. Look at this answer for more info.
RelativeLayout
ViewParent
android:id=@+id/myParentViewId