Android Question Save state e values Radio buttons

phcoelho

New Member
I'm developing a screen that will contain questions of a certain questionnaire, I would like to save the values and the state of the radio buttons, how to proceed?

follows a section that assembles the structure of the questionnaire

B4X:
For i = 0 To lblperg2.Length -1
        CursorTest.Position = i
    If CursorTest.GetString("id_tppe") = 1 Then

        '-------INICIALIZAR OS COMPONENTES --------
        lblperg2(i).Initialize("lblPerg"&i)
        rbtTest1.Initialize("rbtTest"&i)
        pnlRadioBtn.Initialize("pnlRadioBtn"&i)     
        rbtTest1.Text = "Sim"     
        rbtTest1.TextSize=12
        rbtTest3.Initialize("rbtTest_"&i)
        rbtTest3.Text = "Não"
        rbtTest3.TextSize=12
      
        '------- Atribui a descrição da pergunta a label -------
        lblperg2(i).Text= CursorTest.GetString("descricao")
      
        '------ Espaçamento de pergunta para outra  ---------
        numTop = numTop + 100
      
        '-------------- Adiciona os Componentes ao panel ---------
      
      
        pnlRadioBtn.AddView(lblperg2(i),0,numTop,500,40)
        pnlRadioBtn.AddView(rbtTest1,400,numTop,200,65)
        pnlRadioBtn.AddView(rbtTest3,550,numTop,200,65)
        pnlRadioButtons.AddView(pnlRadioBtn,0,0,pnlWidth,pnlHeight)
      
        End If
      
        If CursorTest.GetString("id_tppe") = 2 Then
            Log("Aqui a pergunta será checkbox")
            lblperg2(i).Initialize("lblPerg"&i)
            edtResp.Initialize("edtResp"&i)
          
            pnlRadioBtn.Initialize("pnlRadioBtn"&i)
            lblperg2(i).Text= CursorTest.GetString("descricao")
            numTop = numTop + 100
            pnlRadioBtn.AddView(lblperg2(i),0,numTop,500,40)
            pnlRadioBtn.AddView(edtResp,350,numTop,320,100)     
            pnlRadioButtons.AddView(pnlRadioBtn,0,0,pnlWidth,pnlHeight)
          
          
        End If
      
        If CursorTest.GetString("id_tppe") = 3 Then
            Log("Aqui a pergunta será Texto")
            lblperg2(i).Initialize("lblPerg"&i)
            edtResp.Initialize("edtResp"&i)
          
            pnlRadioBtn.Initialize("pnlRadioBtn"&i)
            lblperg2(i).Text= CursorTest.GetString("descricao")
            pnlRadioBtn.AddView(lblperg2(i),0,numTop,500,40)
            pnlRadioBtn.AddView(edtResp,140,numTop,180,50)
            pnlRadioButtons.AddView(pnlRadioBtn,0,0,pnlWidth,pnlHeight)
        End If
    Next
 

Attachments

  • quest.png
    quest.png
    86 KB · Views: 270
Top