在Android中动态添加多个无线电组按钮

时间:2016-02-27 01:06:09

标签: android android-layout radio-button survey android-radiogroup

我在Android Studio中有这个结构:

  

问题1

     

RadioGroup1

     
      
  • RadioButton1      
        
    • RadioButton2
    •   
    • RadioButton3
    •   
    • RadioButton4
    •   
  •   
     

问题2

     

RadioGroup2

     
      
  • RadioButton5      
        
    • RadioButton6
    •   
    • RadioButton7
    •   
    • RadioButton8
    •   
  •   
     

问题3

     

RadioGroup3

     
      
  • RadioButton9      
        
    • RadioButton10
    •   
    • RadioButton11
    •   
    • RadioButton12
    •   
  •   
     

问题4

     
      
  • CheckBox1      
        
    • CheckBox2
    •   
    • CheckBox3
    •   
    • CheckBox4
    •   
  •   

RadioGroup,RadioButton和Checkbox是在运行时创建的,所有内容都是在LinearLayout中添加的。

如何获得Radiobutton9,Checkbox1,Checkbox3等的价值

1 个答案:

答案 0 :(得分:0)

您可以维护所有单选按钮和复选框,如下例所示

(Pdb) print request
<WSGIRequest
path:/,
GET:<QueryDict: {}>,
POST:<QueryDict: {}>,
COOKIES:{'csrftoken': 'ieefjZZJjeif993i4nfmnkZZKJ',
 'messages': '2f148ec0f66f94740a8ff273dd544b554d28c96c$[["__json_message",0,20,"The
tool \\"U7316\\" was added successfully."],["__json_message",0,20,"The
tool \\"U7321\\" was added successfully."],["__json_message",0,20,"The
tool \\"SEMA116\\" was added
successfully."],["__json_message",0,20,"The tool \\"U7324\\" was added
successfully."],["__json_message",0,20,"The tool \\"U7324\\" was
changed successfully."],["__json_message",0,20,"The tool \\"SEMA116\\"
was changed successfully."],["__json_message",0,20,"The tool
\\"U7331\\" was added successfully."],["__json_message",0,20,"The tool
\\"SEMA207\\" was added successfully."]]',
 'sessionid': 'xg254b6ki5m981n8oko4n88jnqsj0m1y'},
META:{'Apple_PubSub_Socket_Render': '/tmp/launch-FIgPyl/Render',
.
.
.