java - Assigning ArrayList value into a Variable -


i having problem on how can pass values of arraylist in variable. there way can acquire values of different radio button single variable. here's program comment

arraylist < string > list1 = new arraylist < string > (); string rg1 = "*"; string rg2 = "*"; string rg4 = "*"; string rg5 = "*"; list1 = "*"; // getting error here accepts string , how  declare list1 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 part, how can assign arraylist values here ? fragment = new schoollistfragmentfilter(); getsupportfragmentmanager()     .begintransaction()     .add(r.id.content_frame, fragment)     .addtobackstack(null).commit(); mdrawerlayout.closedrawer(explistview); dia.dismiss(); 

here's filter values radio buttons

if (sreg[loop].equalsignorecase(thisfilter[0])                 && sadmin[loop].equalsignorecase(thisfilter[1])                 && sambience[loop].equalsignorecase(thisfilter[3])                 && amounttf >= thetuitionfee                 && sspecialty[loop][subloop].equalsignorecase(thisfilter[4])                 && sspecialty[loop][subloop].equalsignorecase(thisfilter[6]) 

here's additional program in order filter sreg , select rest.

(sreg[loop].equalsignorecase((string)thisfilter[0])                 && ((string)thisfilter[1]).equalsignorecase("*")                 && ((string)thisfilter[3]).equalsignorecase("*")                  && amounttf == 0                 && ((string)thisfilter[4]).equalsignorecase("*")                 && ((string)thisfilter[6]).equalsignorecase("*")) {             list.add(slist[loop]); 

replace list1 = "*"; list1.add("*");

or can in constructor this:

list<string> list1 = new arraylist<>(arrays.aslist("val1", "val2", "val3")); 

this thefilter[6] = list1; possible edit below.

edit:

replace string thefilter[]=newstring[6] object thefilter[]=new object[6] ,

if (sreg[loop].equalsignorecase(thisfilter[0])                 && sadmin[loop].equalsignorecase(thisfilter[1])                 && sambience[loop].equalsignorecase(thisfilter[3])                 && amounttf >= thetuitionfee                 && sspecialty[loop][subloop].equalsignorecase(thisfilter[4])                 && sspecialty[loop][subloop].equalsignorecase(thisfilter[6]) 

by:

if (sreg[loop].equalsignorecase((string)thisfilter[0])                 && sadmin[loop].equalsignorecase((string)thisfilter[1])                 && sambience[loop].equalsignorecase((string)thisfilter[3])                 && amounttf >= thetuitionfee                 && sspecialty[loop][subloop].equalsignorecase((string)thisfilter[4])                 && filtered(sspecialty[loop][subloop], (list<string>)thisfilter[6])) 

and filtered method:

private boolean filteredone(string val, list<string> values) {   boolean b = false;   for(string s:values) {     b |= s.equalsignorecase(val);   }   return b;// true if 1 equal }  private boolean filteredall(string val, list<string> values) {   boolean b = true;   for(string s:values) {     b &= s.equalsignorecase(val);   }   return b;// true if equal } 

Comments