如何从android listview中的json动态创建视图?

Sha*_*a M 2 android json android-view

我想从Web服务动态创建单选按钮,复选框,微调器.以下是我的回复.

{
    "getSurvey": {
        "ErrorCode": "0",
        "Result": "Success",
        "Response": [
            {
                "SurveyId": "91",
                "SurveyName": "Sample Survey",
                "Questions": [
                    {
                        "QuestionId": "553",
                        "QuestionText": "<p style=\"margin: 0px; text-align: left;\">Are you satisfied with Cement Quality?</p>",
                        "Type": "RadioButtonList",
                        "Mandatory": "Y",
                        "OptionValue": [
                            {
                                "AnswerId": "2220",
                                "AnswerValue": "Excellent"
                            },
                            {
                                "AnswerId": "2221",
                                "AnswerValue": "Good"
                            },
                            {
                                "AnswerId": "2222",
                                "AnswerValue": "Satisfactory"
                            },
                            {
                                "AnswerId": "2223",
                                "AnswerValue": "Poor"
                            }
                        ]
                    },
                    {
                        "QuestionId": "554",
                        "QuestionText": "How will you rate Cement? (0= Lowest and 7= Highest)&nbsp;",
                        "Type": "DropDownList",
                        "Mandatory": "Y",
                        "OptionValue": [
                            {
                                "AnswerId": "2224",
                                "AnswerValue": "0"
                            },
                            {
                                "AnswerId": "2225",
                                "AnswerValue": "1"
                            },
                            {
                                "AnswerId": "2226",
                                "AnswerValue": "2"
                            },
                            {
                                "AnswerId": "2227",
                                "AnswerValue": "3"
                            },
                            {
                                "AnswerId": "2228",
                                "AnswerValue": "4"
                            },
                            {
                                "AnswerId": "2229",
                                "AnswerValue": "5"
                            },
                            {
                                "AnswerId": "2230",
                                "AnswerValue": "6"
                            },
                            {
                                "AnswerId": "2231",
                                "AnswerValue": "7"
                            }
                        ]
                    },
                    {
                        "QuestionId": "555",
                        "QuestionText": "What Kind of issues you face while Delivery?",
                        "Type": "ListBox",
                        "Mandatory": "Y",
                        "OptionValue": [
                            {
                                "AnswerId": "2232",
                                "AnswerValue": "Logistic Issue"
                            },
                            {
                                "AnswerId": "2233",
                                "AnswerValue": "Material Handeling "
                            },
                            {
                                "AnswerId": "2234",
                                "AnswerValue": "Stock not available"
                            },
                            {
                                "AnswerId": "2235",
                                "AnswerValue": "Wastage of Cement"
                            },
                            {
                                "AnswerId": "2236",
                                "AnswerValue": "Others"
                            }
                        ]
                    },
                    {
                        "QuestionId": "559",
                        "QuestionText": "Do you like Cement?",
                        "Type": "CheckBoxList",
                        "Mandatory": "Y",
                        "OptionValue": [
                            {
                                "AnswerId": "2237",
                                "AnswerValue": "Yes"
                            },
                            {
                                "AnswerId": "2238",
                                "AnswerValue": "No"
                            }
                        ]
                    }
                ]
            }
        ]
    }
} 
Run Code Online (Sandbox Code Playgroud)

基于类型我需要动态创建视图.请有人给我一个想法或解决方案如何实现这一目标.动态创建视图后,我需要从创建的视图中获取所有选定的值.

谢谢.

Dar*_*try 7

您可以使用json2view库来创建动态视图.

https://github.com/Avocarrot/json2view