获取子视图中的RelativeLayout视图、RelativeLayout

由网友(三分靠运气七分靠打拼)分享简介:我想在我的活动,将返回相对布局的所有子视图中添加一个按钮。 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....
  }
阅读全文

相关推荐

最新文章