Getting radio button value from custom list in android

前端 未结 3 1864
深忆病人
深忆病人 2021-01-25 09:32

I have a custom listview and a radio button in each row, it works properly but i want to reach id of selected radio button from this code. For example when i need the textview1

3条回答
  •  深忆病人
    2021-01-25 10:20

    Code like this in your button onClick

     int selected_radioISAwayGroup = holder.radioISAwayGroup.getCheckedRadioButtonId();
                    holder.radioISAwayButton = (RadioButton) findViewById(selected_radioISAwayGroup);
    
                    System.out.println("holder.radioISAwayButton:"+holder.radioISAwayButton.getText().toString());
                    if(holder.radioISAwayButton.getText().toString().equalsIgnoreCase("Pre"))
                    {
                        //Count +1 for presents
                    }
                    else if(holder.radioISAwayButton.getText().toString().equalsIgnoreCase("Abs"))
                    {
                        //Count +1 for Absents
                    }
                    else
                    {
                        //Count +1 for Half
                    }
    

提交回复
热议问题