java - 如何从android中的线性布局中获取视图?
问题描述
我想从 Linearlayout 获得不同的视图,但它总是让我成为其中之一。这是我的代码:
int count = LinearLayoutItemHolder.getChildCount() ;
for(int i = 0 ; i <count ; i++){
Customview cs = LinearItemHolder.getChildAt(i) ;
Log.d(TAG,"value of cs " + cs) ;
Log.d(TAG,"value : " + cs.txtText.getText() ) ;
}
我的 LinearLayoutHolder 有 3 个孩子,但它总是返回我最后一个。
cs id 的值:
run: com.example.mine.happyp.View.CustomView{2a6e0e3 V.E...... ......I. 0,0-0,0}
run: com.example.mine.happyp.View.CustomView{c251ae0 V.E...... ......I. 0,0-0,0}
run: com.example.mine.happyp.View.CustomView{33ce199 V.E...... ......I. 0,0-0,0}
run: 3
run: com.example.mine.happyp.View.CustomView{2fedc5e V.E...... ........ 0,0-720,660}
run: com.example.mine.happyp.View.CustomView{c5ca83f V.E...... ........ 0,660-720,1320}
run: com.example.mine.happyp.View.CustomView{e71050c V.E...... ........ 0,1320-720,1980}
解决方案
推荐阅读
- android - 如何在自定义适配器中跟踪我选中的复选框?
- java - 如何在我的代码中放置输入流进度监视器?
- angular - 如何使用具有默认值的输入变量的设置方法?
- unix - 将多个文件从本地 unix 移动到 HDFS
- ms-access - 如何在与表中的值相关的多选列表框中自动选择项目?
- mysql - [Ollivander 在hackerrank 上的库存问题] 在组中替代部分(非聚合列)
- javascript - $(this).prop('checked') 不适用于检查 Jquery 的复选框
- c# - Xamarin.Forms ListView 大小到内容
- terraform - 在私有 VPC 中创建 aws sagemaker 笔记本实例时的直接互联网访问功能
- selenium - Selenium 需要显示器吗