0

I am building an android application where I am creating multiple checkBox in linear layout. Below is my code

//Make multi leg info display to user
    for(int i = 0; i < PickerForm.GoogleAddress.size(); i++) {
        LayoutInflater inflater = null;
        inflater = (LayoutInflater) getApplicationContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View mLinearView = inflater.inflate(R.layout.custome_leg_detail, null);
        TextView legName = (TextView) mLinearView.findViewById(R.id.legName);
        TextView legPhone = (TextView) mLinearView.findViewById(R.id.legPhoneNumber);
        TextView legAddress = (TextView) mLinearView.findViewById(R.id.legAddress);
        TextView legCashToPick = (TextView) mLinearView.findViewById(R.id.legCashToPick);
        final CheckBox radioButtonCashToCollect = (CheckBox) mLinearView.findViewById(R.id.radioButtonCashToCollect);
        radioButtonCashToCollect.setTag(String.valueOf(i));        
           legLinearLayout.addView(mLinearView);
        }

I want there should be only one checkBox clicked at a time.

sofquestion 9
  • 167
  • 4
  • 12

2 Answers2

1

I think you should use RadioGroups, in your case. those are specifically for your case, only one checked at time.

KRist
  • 1,402
  • 12
  • 10
  • I am creating dynamic radio button – sofquestion 9 Nov 05 '15 at 13:37
  • that doesnt make any problem, just add them dynamically inside the radiogroup take a look at this: http://stackoverflow.com/questions/19380526/how-to-add-radio-button-dynamically-as-per-the-given-number-of-counts – KRist Nov 05 '15 at 13:53
0

You can use RadioButton for this purpose.

Take a look here

Bhargav Thanki
  • 4,924
  • 2
  • 37
  • 43