get parent's view from a layout

后端 未结 7 2399
囚心锁ツ
囚心锁ツ 2020-12-25 09:54

I have a FragmentActivity with this layout:




        
7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-25 10:20

    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.

提交回复
热议问题