I am extending BaseAdapter in an android listview with a custom adapter as so:
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = getLayoutInflater();
View row;
row = inflater.inflate(R.layout.listview, parent, false);
TextView textview = (TextView) row.findViewById(R.id.tv_main);
ImageView imageview = (ImageView) row.findViewById(R.id.iv_main);
textview.setText(data_text[position]);
imageview.setImageResource(data_image[position]);
imageview.setScaleType(ScaleType.FIT_XY);
return (row);
}
which shows my list; I then attach a longClickListener to raise a context menu, which offers a delete option. The problem is that, after removing the indexed position in the list, any reference to that position subsequently throws an exception. I've tried notifyDataSetChanged in lots of different forms, with no success. I've tried ArrayAdapter, but run into the same issue. There must be some way around this, but I'm striking out. Any suggestions or links would be appreciated!