循环 获取RecyclerView item 控件 及数据

本文介绍了一种从RecyclerView中循环获取子项的方法,并展示了如何通过键值对形式存储TextView和EditText的值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  • 截取部分项目demo  循环获取RecyclerView item 的 RelativeLayout 下面的 TextView  和 EditText 的 值 ,以键值对形式保存
    
    ArrayList<Map<String, String>> houseRes = new ArrayList<>();
    
    RecyclerView recy = findViewById(R.id.recy_setting);
    
    for (int i = 0; i < recy.getChildCount(); i++) {
        Map<String, String> mDeviceHeaderMap = new HashMap<>();
       
        RelativeLayout layout = (RelativeLayout) recy.getChildAt(i);
        TextView tv_content = layout.findViewById(R.id.tv_content);
        EditText tv_description = layout.findViewById(R.id.tv_content_description);
       
        mDeviceHeaderMap.put(tv_content.getText().toString(), tv_description.getText().toString());
    
        houseRes.add(mDeviceHeaderMap);
    }
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值