java - Update listview from inside the list adapter -


here's problem: have listview several rows. rows have single type of listadapter(though there several types of rows). if user selects row, row needs un-selected. way row selected dependent on row type. rows selected when have written in edittext field,etc. suffice say, row selection algorithm must inside listadapter class.

one solution used have "selection" display algorithm @ getview() row initialization part , when row selected, call notifiy this.notifydatasetchanged(); refreshing entire listview. this, of course, costly , causes whole other set of issues.

so need way update other rows inside listview within custom adapter class. how access selected row's "brothers" ?

any input appreciated! thanks!

well, astute colleague, believe have found solution problem:

use listview need constructor custom adapter!

so in custom adapter constructor :

    public subeventlistadapter(context context, arraylist<mobilesubevent> items,  mobilesubactivity parentsubactivity, listview listview)         {             super(context, r.layout.view_select_event_item, items);             this._items = items;             this._context = context;             this.parentsubactivity = parentsubactivity;             this.listview = listview;         } 

and in activity set adapter so:

listview.setadapter(new subeventlistadapter(listview.getcontext(), subactivity.get_subeventslist(), subactivity, listview)); 

now, in adapter, can use listview please; example:

    private void addalldots()     {         for(int = 0 ; i< listview.getchildcount(); i++)         {             view v = listview.getchildat(i);             imageview dots = (imageview) v.findviewbyid(r.id.ivmandselection);             dots.setvisibility(view.visible);         }     } 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -