searchable spinner not working in Android Java -


i have java.lang.unsupportedoperationexception @ iterator .remove() believe considered safe , think code "ok" can me?

    final list<string> livelist = arrays.aslist((string[]) button.getitems().toarray()); //create mutable list<string> button.getitems() list<string>      final premspinner dropdown = new premspinner(this); //spinner (eg: "dropdown") of options     dropdown.setlayoutparams(col);     final arrayadapter<string> dataadapter = new arrayadapter<string>(this, android.r.layout.simple_spinner_item, livelist);        //      <---+     dataadapter.setdropdownviewresource(android.r.layout.simple_spinner_dropdown_item);                                             //          |     dropdown.setpadding(45, 15, 45, 15);                //                                                                                      |     dropdown.setadapter(dataadapter);                   //the way [populate] `dropdown(spinner)` via `adapter` , list<string>   |              final edittext partsearcher = new edittext(this);     partsearcher.setlayoutparams(col);     partsearcher.addtextchangedlistener(new textwatcher() {         public void aftertextchanged(editable s) {             log.w("typing",s.tostring());             iterator<string> iter = livelist.iterator();              while (iter.hasnext()) {                 if (!iter.next().contains(s)) {                     iter.remove();  //<--the unsupportedoperationexception here                 }             }             dataadapter.notifydatasetchanged();         }         public void beforetextchanged(charsequence s, int start, int count, int after) {}         public void ontextchanged(charsequence s, int start, int before, int count) {}     }); 

then add them table

    tr = new tablerow(this);             tr.setlayoutparams(lp);     tr.addview(partsearcher);     table.addview(tr, new tablelayout.layoutparams(layoutparams.wrap_content, layoutparams.wrap_content));      tr = new tablerow(this);         tr.setlayoutparams(lp);     tr.addview(dropdown);            table.addview(tr, new tablelayout.layoutparams(layoutparams.wrap_content, layoutparams.wrap_content)); //this makes fat enough 

the code designed portable people want text search in spinner, there lot of interest in dynamic spinner no solid workable code examples, hoping make 1 blog article, can't figure out!

the iterator in case based on list not support remove();

you need pass in actual object or index of object want remove.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -