how handle using 1 arrayadapter 4 different listviews. have 4 different arraylists passing arrayadapter. instead of copy , paste make 4 arrayadapter classes identical except few lines specific arraylist entered adapter. how using same arrayadapter class 4 separate arraylists?
the problem need arrayadapter know of 4 arraylists entered because have switch statement inside of adapter class method.
in case should add 1 parameter variable constructor of arrayadapter class, identifier of 4 arraylists entered? int?
because adapter class extends arrayadapter class how this? add 1 more variable position in constructor parameter , leave super call same before this?
super(context, textviewresourceid, objects);
how handle problem?
// array adapter enter array selectorlistadapter adapter = new selectorlistadapter(activity, r.layout.row_layout, smalltank2listinfo1array); selectorlistadapter adapter2 = new selectorlistadapter(activity, r.layout.row_layout, smalltank2listinfo2array); selectorlistadapter adapter3 = new selectorlistadapter(activity, r.layout.row_layout, smalltank2listinfo3array); selectorlistadapter adapter4 = new selectorlistadapter(activity, r.layout.row_layout, smalltank2listinfo4array); // set array adapter listview listviewone.setadapter(adapter); listviewtwo.setadapter(adapter2); listviewthree.setadapter(adapter3); listviewfour.setadapter(adapter4); public class selectorlistadapter extends arrayadapter<checkboxlistinfo>{ arraylist<checkboxlistinfo> objects; context context; int textviewresourceid; private string templabel; private boolean ischecked; public selectorlistadapter(context context, int textviewresourceid, arraylist<checkboxlistinfo> objects) { super(context, textviewresourceid, objects); this.context = context; this.textviewresourceid = textviewresourceid; this.objects = objects; }
actually have answered yourself
how using same arrayadapter
class 4 separate arraylists
? --yes can use.
to identify different arrayadapter
s can pass variable constructor stored in local variable. depending on value of variable can decide want do.
while calling constuctor of super class leave variable , call super
()
Comments
Post a Comment