Android:getElementsByTagName 等效吗?
是否可以搜索视图的层次结构并获取特定类型的视图?
相当于 JS 中的 getElementsByTagName
定义如下:
public ArrayList<T> getElementsByTagName(View v, Class<T>){
....
}
调用类似:
ArrayList<TextView> labels = getElementsByTagName(parentView, TextView.class);
Is it possible to search the hierarchy of View and get Views of particular type?
Equivalently to getElementsByTagName
in JS
defined like this:
public ArrayList<T> getElementsByTagName(View v, Class<T>){
....
}
called similar to this:
ArrayList<TextView> labels = getElementsByTagName(parentView, TextView.class);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ViewGroup 具有
getChildCount()
和getChildAt()
这样你就可以遍历树并过滤你想要的孩子。ViewGroup has
getChildCount()
andgetChildAt()
so you can traverse the tree and filter the children you want.