Android的 - 进去一查看孩子吗? [英] Android - get children inside a View?

查看:144
本文介绍了Android的 - 进去一查看孩子吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于一个视图我怎样才能得到它里面的孩子的意见?

所以,我有一个自定义视图和调试器显示,根据 mChildren 还有7其它视图。 我需要一种方法来访问这些观点,但它似乎并不像有一个公共API来做到这一点。

有什么建议?

编辑:

我的自定义视图继承自适配器视图

解决方案

 的for(int i = 0;我≤((ViewGroup中)V).getChildCount(); ++ I) {
    视图nextChild =((的ViewGroup)ⅴ).getChildAt(ⅰ);
}
 

Given a View how can I get the child views inside it?

So I have a custom View and debugger shows that under mChildren there are 7 other views. I need a way to access these views but it doesn't seem like there is a public API to do this.

any suggestions?

EDIT:

My custom view inherits from AdapterView

解决方案

for(int i=0; i<((ViewGroup)v).getChildCount(); ++i) {
    View nextChild = ((ViewGroup)v).getChildAt(i);
}

这篇关于Android的 - 进去一查看孩子吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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