java - Adding/Removing Strings in an ArrayList by Checkbox -



java - Adding/Removing Strings in an ArrayList<String> by Checkbox -

i running issue in regards adding/removing strings have been added arraylist everytime checkbox checked or unchecked.

the issue seems string getting duplicated when more 1 checkbox checked. if check 1st box, add together array. if uncheck first box remove array. issue arises when sec check box. when press checkbox appears add together previous checkboxes string, , 2 of current string.

only first checkbox checked 10-29 14:46:10.051: e/pages(14154): [alertpage] 2 checkboxes checked 10-29 14:46:10.051: e/pages(14154): [alertpage, alertpage, automationpage]

and pattern continues each additional checkbox

any ideas why occurring?

strong text

if (mcheckboxalerts.ischecked()) { malertspermlayout.setvisibility(linearlayout.visible); pagearray.add("alertpage"); } else { malertspermlayout.setvisibility(linearlayout.gone); pagearray.remove("alertpage"); } if (mcheckboxautomation.ischecked()) { mautomationpermlayout.setvisibility(linearlayout.visible); pagearray.add("automationpage"); } else { mautomationpermlayout.setvisibility(linearlayout.gone); pagearray.remove("automationpage"); }

here how converting string

string pagestring = pagearray.tostring(); log.e("pages", pagestring);

every time adding checkbox still checking see if previous checkbox checked. if is adding object same string arraylist. need check if arraylist contains string don't add together if does. recommend using set instead of arraylist. not allow duplicates arraylist will.

java android string checkbox arraylist

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -