-1

I am making an application that has list and Radio Buttons. My Layout contains of the following : a list , A button .

The List contains of Radio buttons. Two radio Buttons. After checking the buttons. I want to make a loop that reads the values of how many are in Button one and how many in Button Two. This is how I have done so far.

        ListViewStudentEditAbsence country ;

            for(int i=0;i<listViewStudentNames.size();i++) {
                country = listViewStudentNames.get(i);
                if (country.getAbsence()==1) {
                    Absence[i] = "1";
                } else {
                    Absence[i] ="0";
                }
            }

But It doesn't seem to work.

ama989
  • 463
  • 1
  • 5
  • 23

2 Answers2

0

https://stackoverflow.com/questions/11194515/android-get-value-of-the-selected-radio-button

Android getting value from selected radiobutton

Hope it works. This two links give you proper knowledge about fetching value.

Community
  • 1
  • 1
akhil batlawala
  • 1,066
  • 1
  • 10
  • 30
0

In your CustomAdapter getView() method

int value=0; //globally
    RadioGroup radioGroup = (RadioGroup) convertView.findViewById(R.id.yourRadioGroup);        
        radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() 
        {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                // checkedId is the RadioButton selected
                  if (checkedId == R.id.rbutton1) {
                    value=10;  //a's value
                } else if (checkedId == R.id.rbutton2) {
                    value=20; //b's value
                }
            }
        });
Rajan Kali
  • 12,627
  • 3
  • 25
  • 37
  • I have tried that, My app crashed. Indeed, I want to make a loop that starts with a click of a button in my activity. The loop reads each radio Button and their values are stored in an array. – ama989 Sep 30 '15 at 07:30