相对于JsonArray大小动态添加radiogroup

时间:2018-04-24 11:04:21

标签: java android arrays android-recyclerview radio-group

我在jsonArray中有一个json数组,我需要根据内部数组长度在radiogroup中添加radioButton的数量。请建议我这样做的方法。从代码我需要根据predefinedAnswersOptions数组的大小设置radiobuttons的数量。因为数组的大小是可变的而不是。

"subServices": [
        {
            "id": 7,
            "questions": [
                {
                    "id": 6,
                    "question": "Brand ?",
                    "isActiveQuestion": true,
                    "isOptionBased": true,
                    "isDescriptive": false,
                    "isSpecificQuestion": true,
                    "isGeneralQuestion": false,
                    "isMultipleSet": true,
                    "hasPriceList": true,
                    "hasQty": true,
                    "maxQty": 5,
                    "predefinedAnswersOptions": [
                        {
                            "id": 13,
                            "options": "Samsung",
                            "isActiveOption": true,
                            "isSpecificQuestion": true,
                            "isGeneralQuestion": false
                        },
                        {
                            "id": 14,
                            "options": "Sony",
                            "isActiveOption": true,
                            "isSpecificQuestion": true,
                            "isGeneralQuestion": false
                        }
                    ]
                },
                {
                    "id": 8,
                    "question": "Installation/Repair ?",
                    "isActiveQuestion": true,
                    "isOptionBased": true,
                    "isDescriptive": false,
                    "isSpecificQuestion": true,
                    "isGeneralQuestion": false,
                    "isMultipleSet": true,
                    "hasPriceList": true,
                    "hasQty": true,
                    "maxQty": 5,
                    "predefinedAnswersOptions": [
                        {
                            "id": 30,
                            "options": "Installation",
                            "isActiveOption": true,
                            "isSpecificQuestion": true,
                            "isGeneralQuestion": false
                        },
                        {
                            "id": 31,
                            "options": "Repair",
                            "isActiveOption": true,
                            "isSpecificQuestion": true,
                            "isGeneralQuestion": false
                        }
                    ]
                },
                {
                    "id": 9,
                    "question": "Type of TV ?",
                    "isActiveQuestion": true,
                    "isOptionBased": true,
                    "isDescriptive": false,
                    "isSpecificQuestion": true,
                    "isGeneralQuestion": false,
                    "isMultipleSet": true,
                    "hasPriceList": true,
                    "hasQty": true,
                    "maxQty": 5,
                    "predefinedAnswersOptions": [
                        {
                            "id": 19,
                            "options": "LCD",
                            "isActiveOption": true,
                            "isSpecificQuestion": true,
                            "isGeneralQuestion": false
                        },
                        {
                            "id": 20,
                            "options": "LED",
                            "isActiveOption": true,
                            "isSpecificQuestion": true,
                            "isGeneralQuestion": false
                        }
                    ]
                }
            ],
    

0 个答案:

没有答案