获取子视图中的RelativeLayout [英] Get Child view in a RelativeLayout

查看:157
本文介绍了获取子视图中的RelativeLayout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的活动,将返回相对布局的所有子视图中添加一个按钮。

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....
  }

这篇关于获取子视图中的RelativeLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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