My nightmare was removing items from the ArrayAdapter<String>
. I have been avoiding this method for almost 6 years because of this phenomenon :(
My Adapter was been:
private class MyAdapter extends ArrayAdapter<String> {
private final Context context;
private final Bitmap[] slike;
private final String[] nazivi;
private final String[] grad_freq;
private final boolean[] omiljeni;
MyAdapter (Context c, Bitmap[] slike, String[] nazivi, String[] grad_freq, boolean[] omiljeni) {
super(c, R.layout.row, R.id.textView1, nazivi);
this.context = c;
this.slike = slike;
this.nazivi = nazivi;
this.grad_freq= grad_freq;
this.omiljeni = omiljeni;
}
// ...
}
And now, it look like:
private class MyAdapter extends ArrayAdapter<String> {
private final Context context;
private final ArrayList<Bitmap> slike;
private final ArrayList<String> nazivi;
private final ArrayList<String> grad_freq;
private final ArrayList<Boolean> omiljeni;
MyAdapter (Context c, ArrayList<Bitmap> slike, ArrayList<String> nazivi, ArrayList<String> grad_freq, ArrayList<Boolean> omiljeni) {
super(c, R.layout.row, R.id.textView1, nazivi);
this.context = c;
this.slike = slike;
this.nazivi = nazivi;
this.grad_freq= grad_freq;
this.omiljeni = omiljeni;
}
// ...
}
Of course, after deleting the desired items, be sure to call:
adapter.notifyDataSetChanged();
Thanks for answers here.