how do i handle using one arrayAdapter for 4 different listviews. I have a 4 different ArrayLists that I am passing into the arrayAdapter. Instead of copy and paste to make 4 ArrayAdapter classes that would be identical except for a few lines specific to the arrayList that was entered into the adapter. How about using the same arrayAdapter class for 4 separate arrayLists?
the problem is i need the ArrayAdapter to know which of the 4 arrayLists was entered because i have a switch statement inside of the Adapter class method.
in this case should i add one extra parameter variable to the constructor of this ArrayAdapter class, as identifier for which of the four arraylists was entered? like an int?
because my adapter class extends ArrayAdapter class how would i do this? would i just add one more variable position in the constructor parameter and then leave the super call the same as before like this?
super(context, textViewResourceId, objects);
how would you handle this problem?
// array adapter where you enter the 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 to 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;
}
enum
etc etc. – Luksprog Jul 11 '13 at 12:01