0

I'm doing a social application with a listview to show information from database. When I see the listview works fine but if I add a new data from the application and then I go to the listview again the application crashes. I think the problem is because I don't implement notifyDataSetChanged() and I have to do, but I don't know how can I do this. At first I have a function to receive the photos and the information from the database and then I have a class ImageAdapter extends BaseAdapter. I think that this method must be placed inside this class:

 class ImageAdapter extends BaseAdapter {

    private Context mContext;

    public ImageAdapter(Context context) {
        mContext = context;
    }

    public int getCount() {
        return MyArrList.size();
    }

    public Object getItem(int position) {
        return MyArrList.get(position);
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {

Somebody knows how implement this function in my applciation?

The exception is the following:

    java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. Make sure your adapter calls notifyDataSetChanged() when its content changes. [in ListView(2131165257, class android.widget.ListView) with Adapter(class com.xx.xx.app.Listview$ImageAdapter)]

Thanks

CapAm
  • 217
  • 3
  • 18

0 Answers0