mercredi 15 juillet 2015

Assigning ArrayList value into a Variable

I am having a problem on how can I pass all values of an arrayList in the variable. Is there a way I can acquire all values of different radio button into a single variable. Here's my program with comment

ArrayList < String > list1 = new ArrayList < String > ();
String rg1 = "*";
String rg2 = "*";
String rg4 = "*";
String rg5 = "*";
list1 = "*"; // Getting error here it only accepts string , how  declare list1 with ArrayList
theFilter[5] = "0";
if (cbRegAffil.isChecked()) {
    int reg = rgRegAffil.getCheckedRadioButtonId();
    RadioButton rBtReg = (RadioButton) dia.findViewById(reg);
    rg1 = (String) rBtReg.getText();

}
if (cbAdmin.isChecked()) {
    int adm = rgAdmin.getCheckedRadioButtonId();
    RadioButton rBtAdm = (RadioButton) dia.findViewById(adm);
    rg2 = (String) rBtAdm.getText();
}

if (cbAmbience.isChecked()) {
    int amb = rgAmbience.getCheckedRadioButtonId();
    RadioButton rBtAmbience = (RadioButton) dia.findViewById(amb);
    rg4 = (String) rBtAmbience.getText();
}
if (cbTuition.isChecked()) {
    theFilter[5] = spin.getSelectedItem()
        .toString();
}

if (cbSpecialty.isChecked()) {
    int spec = rgSpecialty.getCheckedRadioButtonId();
    int spec2 = rgSpecialty2.getCheckedRadioButtonId();
    RadioButton rBtSpec = (RadioButton) dia.findViewById(spec);
    RadioButton rBtSpec2 = (RadioButton) dia.findViewById(spec2);
    list1.add((String) rBtSpec.getText());
    list1.add((String) rBtSpec2.getText());

}

TuitionFee = Integer.parseInt(theFilter[5]);
theFilter[0] = rg1;
theFilter[1] = rg2;
theFilter[3] = rg4;
theFilter[4] = rg5;
theFilter[6] = list1; // getting error within this part, how can I assign arrayList values here ?
fragment = new SchoolListFragmentFilter();
getSupportFragmentManager()
    .beginTransaction()
    .add(R.id.content_frame, fragment)
    .addToBackStack(null).commit();
mDrawerLayout.closeDrawer(expListView);
dia.dismiss();




Aucun commentaire:

Enregistrer un commentaire