找到一个&LT;包括&GT;查看由ID? [英] Finding an <include> view by id?
本文介绍了找到一个&LT;包括&GT;查看由ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能找到一个视图通过ID,如果它是一个:?
Is it possible to find a view by id if it's an ?:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<include
android:id="@+id/foo"
layout="@layout/test" />
...
View view = findViewById(R.id.foo);
什么是在这种情况下,意见?它是一个看法?它是否解决到任何布局/测试的顶级元素是?
What is "view" in this case? Is it a view? Does it resolve to whatever the top-level element of "layout/test" is?
感谢
推荐答案
你基本上覆盖顶父视图的ID在包括布局,所以你会得到的是俯视整个的布局和它的内容。该&LT;包括&GT;
标签,实际上,所包含的布局的复制和粘贴。您可以覆盖 ID
标记和布局_
的任何属性。
You're essentially overwriting the ID of the top-parent view in the layout your including, so what you'll get is the top-view of the entire layout and it's contents. The <include>
tag is, in effect, a copy-and-paste of the contained layout. You can override the id
tag and any attribute with layout_
.
这篇关于找到一个&LT;包括&GT;查看由ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文