How to get Activity's content view?

前端 未结 8 648
一向
一向 2020-11-27 09:22

What method should I call to know if an Activity has its contentView (once the method setContentView() has been called)?

相关标签:
8条回答
  • 2020-11-27 10:17
    this.getWindow().getDecorView().findViewById(android.R.id.content)
    

    or

    this.findViewById(android.R.id.content)
    

    or

    this.findViewById(android.R.id.content).getRootView()
    
    0 讨论(0)
  • 2020-11-27 10:20

    You can also override onContentChanged() which is among others fired when setContentView() has been called.

    0 讨论(0)
提交回复
热议问题