为什么 Activity 没有 getContentView() 方法? [英] Why isn't there a getContentView() method for Activity?
本文介绍了为什么 Activity 没有 getContentView() 方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Activity
类有一个 setContentView()
方法.PopupWindow
类有一个 getContentView()
方法,但没有其他方法.还有其他方法可以获取活动的主要内容视图吗?
The Activity
class has a setContentView()
method. The PopupWindow
Class has a getContentView()
method but nothing else does. Is there another way to get the main content view for an activity?
推荐答案
下面这行代码可以解决问题:
Following line will do the trick:
findViewById(android.R.id.content);
本质上是一样的(需要在Activity的上下文中调用)
it is essentially same as (it needs to be called on the context of an Activity)
this.findViewById(android.R.id.content);
这篇关于为什么 Activity 没有 getContentView() 方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文