findViewById(R.id.content)和getRootView的区别() [英] Difference between findViewById(R.id.content) and getRootView()

查看:1481
本文介绍了findViewById(R.id.content)和getRootView的区别()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

findViewById(R.id.content)和getRootView()之间的区别是什么?不要都返回一个活动的根本看法?

What is the difference between findViewById(R.id.content) and getRootView() ? Don't both return the root view of an activity?

推荐答案

该方法的 findViewById(R.id.content) 向下搜索视图层次了ID为内容的查看(它检查自己以及)。

The method findViewById(R.id.content) searches down the view hierarchy for a View with the id content (it examines itself as well).

该方法 getRootView( ) 走了视图层次,直到达到根视图(它会检查自己以及)。

The method getRootView() walks up view hierarchy until it hits the root View (it examines itself as well).

如果您在查看具有ID 内容,它是根视图,那么这些方法会产生相同的结果,否则他们不会。

If the View you are in has the id content and it is the root view then these methods will give the same result, otherwise they won't.

这篇关于findViewById(R.id.content)和getRootView的区别()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆