how can i send radio button value and switch case option to server using json android?

后端 未结 4 1692
忘了有多久
忘了有多久 2021-01-29 10:07

I\'m trying to make a registration form where all values are saving on the server, but i dont know how to send the radio buttons\' value and switch option buttons\' value to ser

4条回答
  •  爱一瞬间的悲伤
    2021-01-29 11:03

    Add a global String variable gender and boolean variable switchValue.

    String gender="Male" ;
    boolean switchValue = false ;
    

    Inside RadioGroupListener Method

     public void addListenerOnButton() {
        RadioGroup rgrp=(RadioGroup)findViewById(R.id.rg);
        rgrp.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if(i==R.id.rgm){
                  gender="Male" ; 
                 }else{
                  gender="Female";
             }
        }
        });
        Toast.makeText(RegistrationForm.this,
                radioButton.getText(), Toast.LENGTH_SHORT).show();
    
    }
    

    For Getting the switch state

    switchValue = swth.isChecked();
    

提交回复
热议问题