Android:getElementsByTagName 等效吗?

发布于 2024-12-25 07:34:44 字数 331 浏览 2 评论 0原文

是否可以搜索视图的层次结构并获取特定类型的视图?

相当于 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我早已燃尽 2025-01-01 07:34:44

ViewGroup 具有 getChildCount()getChildAt() 这样你就可以遍历树并过滤你想要的孩子。

ViewGroup has getChildCount() and getChildAt() so you can traverse the tree and filter the children you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文