on动态列表的RadioGroup嵌套在RecyclerView

on动态列表的RadioGroup嵌套在RecyclerView

本文介绍了如何将带有RadioButton动态列表的RadioGroup嵌套在RecyclerView的每行/项目中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要这样的布局:

红色标题是 dish_options 中的第一级数组,而 RadioButtons 是从<$ c中填充的数组json的 dish_options 内的$ c>项:

The Red titles are the first level array from dish_options and the RadioButtons are a populated from an array itemsinside dish_options of the json:

您可能会注意到 dish_options 是一个数组,可能还有更多该 dish_options 的键之一内的对象可能存储数组。

As you may notice the dish_options is an array, which might have many more object inside one of the keys of this dish_options might store an items arrays.

我尝试使用 getItemViewType()并为第一级 dish_options (红色标题)设置了不同的布局并为在的每一行中都有 RadioButton 问题是我必须使用RadioGroup来制作 RadioButton 唯一(每个广播组仅单击1次)。因此,我对此一无所知,不知道如何进行。

I tried using getItemViewType() and set different layouts for first level dish_options (red title) and implemented a different layout for the RadioButton in each row of itemsthe problem is that I have to use RadioGroup to make RadioButton unique (only 1 click per radiogroup). So I'm stucked with this and no idea how to proceed.

我应该在RecyclerView的每一行中嵌套一个RecyclerView吗?

Should I nest a RecyclerView inside each row of the RecyclerView?

推荐答案

您可以尝试使用此代码

you can give a try to this code https://github.com/h6ah4i/android-advancedrecyclerview

这是一个具有groupSection或GroupItem并由一个recyclerView
维护的适配器。设计不是太复杂,这可能会有所帮助

This is a single adapter having groupSection or GroupItem maintained with one recyclerViewbecause your design is not too much complex thismight be helpful

首先运行 可拖入部分,因为它是...然后根据需要更改布局

first run "draggable with section" as it is ... and then change the layout as per your need

您可能需要使用其方法删除可拖动界面,因为我猜您不需要它们

you may need to remove the draggable interface with its methods as I guess you don't need them

实现DraggableItemAdapter< DraggableWithSectionExampleAdapter.MyViewHolder>

请仔细看一下类,您可能需要以某种方式集成JSON数据这样,或在此类中(如果您不是专家,我建议这样做)在第37-53号注释行中,并尝试使用您的数据进行复制

Carefully have a look at this class and you might need to integrate your JSON data some how in this way, or inside this classes(I suggest if your not an expert) comment line no 37 - 53 and atry to replicate with your data

根据需要从组中选择某些或无项目,...您可以实现一个复选框或切换图像,并将0设置为未选中,将1设置为选中。您的数据类(我是说您是从JSON生成的POJO类,或者甚至可以在json中维护键)

As you required to select some or None Items from the group, ... you can implement a check-box or switch the images and set the 0 for unchecked or 1 for checked to your data class (I'm mean your POJO class you generated from JSON or you can even maintain a key in json )

这篇关于如何将带有RadioButton动态列表的RadioGroup嵌套在RecyclerView的每行/项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 04:04