list - Android Spinner select Characteristics -
i got annoying problem here , hope can me.
i have list of plants (self defined class). these plants got name, id , characteristics. characteristics saved in strings. f.e. characteristic1
size of plant, characteristic2
design of leafs , on..
i have spinners now, , in each of these spinners selection of 1 characteristic should available (spinner1 got characteristics variable characteristics1 plants, ...) goal can use these spinners give user plants, suits user's selection of characteristics.
any ideas how can implement in non-spaghetti way? i'm bit new programming need help.
i hope explained well, it's quite hard me explaining in second language.
my code:
plant - class
private int pd_id; private string pd_plantname; private string pd_longinfo; private string pd_infochar1; private string pd_infochar2; private string pd_infochar3; private string pd_infochar4; private string pd_infochar5;
image-class
private int i_id; private int i_p_id; private string i_path; private calendar i_date;
in activity got list of images , list of plants. fill spinner characteristics use code.
arraylist<string> sinfo1 = new arraylist<string>(); while (i < plantlist.size()) { sinfo1.add(plantlist.get(i).getpd_infochar1()); i++; } arrayadapter<string> spinfo2 = new arrayadapter<string>(this, android.r.layout.simple_spinner_item, sinfo1); spart.settag(1); spart.setadapter(spinfo1); spalter.setonitemselectedlistener(new myonitemselectedlistener(spalter));
i got 5 times 5 spinners. onitemselectedlistener
public void onitemselected(adapterview<?> parent, view view, int position, long id) { if (sp.gettag() == spalter.gettag()) { int i2 = 0; while (i2 < plantlist.size()) { if (plantlist.get(i2).getpd_infochar1() .equalsignorecase((string) sp.getselecteditem())) { } else{ if(((string) sp.getselecteditem()).equalsignorecase("--bitte auswählen--")){ } else{ int pid = plantlist.get(i2).getpd_id(); plantlist.remove(i2); arraylist<image> localilist = getimagelistfromplantid(pid); int x = 0; while (x < localilist.size()){ toast.maketext(entscheidungsbaum.this, localilist.get(x).geti_path(), toast.length_short).show(); imagelist.remove(localilist.get(x)); x++; } } } i2++; } }
so delete each characteristic wrong images imagelist (which source gridview).
firstly, works not well, wrong images... secondly, code bad, know that. can me find better way adapt imagelist spinner selection?
Comments
Post a Comment