如何在android中获取活动视图的引用?
我是android新手..
有什么方法可以获取android中加载的活动视图的引用...? 我想要这样的:::
View v=getTheActiveView();
bool b = v.getKeepScreenOn();//
我想要实现这个方法 getTheActiveView
。
此视图可能是Android 主屏幕,或某些其他应用程序的视图... 我不需要 setter 方法,只需 getKeepScreenOn 等 getter 方法就足够了...
如果有错误,请原谅...
I am new to android..
Is there any way to get the reference of active View loaded in the android...?
I want it some like this:::
View v=getTheActiveView();
bool b = v.getKeepScreenOn();//
I want this method getTheActiveView
to be implemented.
This view may be Android home screen,or some other Application's view...
I dont want setter methods,just getter methods like getKeepScreenOn
,etc is enough...
Pardon me if it is blunder...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您向相关视图添加了标签(无论是从 xml 布局文件扩充它还是以编程方式创建它),您可以在当前显示视图的 Activity 上调用
findViewById(int id)
以获得对其的引用。希望这就是你的意思。If you added a tag to the view in question (whether you inflated it from an xml layout file or created it programmatically), you can call
findViewById(int id)
on the Activity that the view is currently displayed in to get a reference to it. Hope this is what you meant.