0

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!

Barney
  • 2,355
  • 3
  • 22
  • 37
kwishnu
  • 1,730
  • 19
  • 17
  • We need some java code please. – Simon Dorociak Mar 29 '13 at 08:13
  • 1
    insted of array you have to use arraylist. & chekc all answer from this link: http://stackoverflow.com/q/2558591/1168654 – Dhaval Parmar Mar 29 '13 at 08:45
  • @DSP: Thanks for the direction, solved the issue using ArrayAdapter. Also found this link [Custom ArrayAdapter](http://devtut.wordpress.com/2011/06/09/custom-arrayadapter-for-a-listview-android/) very useful for anyone else struggling with this. – kwishnu Mar 29 '13 at 22:09

0 Answers0