Как передать значения радиокнопок из нескольких радиогрупп? Как решить, возвращая первое значение? - PullRequest
0 голосов
/ 11 апреля 2019

снимок экрана Как получить значения из нескольких групп радио и как решить, возвращая только первое значение

 public void onClick(View v) {

            int widepart=radioWidePart.getCheckedRadioButtonId();
            int jawShape=radioJawShape.getCheckedRadioButtonId();
            int faceLength=radiofaceLength.getCheckedRadioButtonId();
            RadioButton foreheard = (RadioButton)findViewById(widepart);
            RadioButton cheekbones = (RadioButton)findViewById(widepart);
            RadioButton pointy=(RadioButton)findViewById(jawShape);
            RadioButton square=(RadioButton)findViewById(jawShape);
            RadioButton flshort=(RadioButton)findViewById(faceLength);
            RadioButton flaverage=(RadioButton)findViewById(faceLength);
            if(foreheard.isChecked()){
                if(pointy.isChecked()){
                    if(flshort.isChecked()){
                        Intent Intents=new Intent(form.this,heart.class);
                        startActivity(Intents);
                        setContentView(R.layout.activity_heart);
                    }
                    else if(flaverage.isChecked()){
                        Intent Intents=new Intent(getApplicationContext(),heart.class);
                        startActivity(Intents);
                        setContentView(R.layout.activity_heart);
                    }
                }

1 Ответ

0 голосов
/ 22 апреля 2019
final RadioGroup radioWidePart= (RadioGroup) findViewById(R.id.widestpart);
final RadioButton forehead=(RadioButton)findViewById(R.id.foreheard);
final RadioButton cheekbone=(RadioButton)findViewById(R.id.cheekbone);
final RadioGroup radioJawShape=(RadioGroup) findViewById(R.id.shapeOfJaw);
final RadioButton pointy=(RadioButton)findViewById(R.id.pointy);
final RadioButton square=(RadioButton)findViewById(R.id.square);
final RadioGroup radiofaceLength=(RadioGroup)findViewById(R.id.faceLength);
final RadioButton flshort=(RadioButton)findViewById(R.id.flshort);
Button btnSubmit=(Button) findViewById(R.id.btnSubmit);
btnSubmit.setOnClickListener(new View.OnClickListener(){
        public void onClick(View v) {
            if(pointy.isChecked()){
                Intent Intents= new Intent(form.this, heart.class);
                startActivity(Intents);
            }}
...