由网友(三分靠运气七分靠打拼)分享简介:我想在我的活动,将返回相对布局的所有子视图中添加一个按钮。 I want to add one button in my activity that will return all child view of relative layout. 我怎样才能获得相对布局视图的所有子视图?How can i get a...
我想在我的活动,将返回相对布局的所有子视图中添加一个按钮。
I want to add one button in my activity that will return all child view of relative layout.
我怎样才能获得相对布局视图的所有子视图?
How can i get all child view of relative layout view?
推荐答案
RelativeLayout的
扩展的ViewGroup
里面有 getChildCount()
和 getChildAt(INT指数)
方法。所以你可以尝试的是:
RelativeLayout
extends ViewGroup
which has the getChildCount()
and getChildAt(int index)
methods. So what you could try is :
for(int i=0;i<relativeLayout.getChildCount();i++){
View child=relativeLayout.getChildAt(i);
//your processing....
}
相关推荐
最新文章