1

I Googled lot about this notifydataset change issue, still i m unable to find answer, i have a listview containing custom object.

My implementation looks like this

1) A list of custom objects 2) A Adapter to which i provide the custom object list

My Quesion:

When i delete any item from list, in backend i'm simply calling remove from the custom object list. and if i call notifyDatasetchanged, its not working :(..

Its not refreshing the list, i dont no where is it missing. Kindly help me what is the procedure to update list in this senarios

Naruto
  • 9,476
  • 37
  • 118
  • 201
  • Please provide some code, are you sure you are calling notifyDataSetChanged on your adapter, not new one? Also check if you are removing item from list which is used by adapter, e.g. adapter has reference to this list. – Dmytro Danylyk Nov 03 '12 at 13:32
  • If you want to get a good answers for your questions, improve your accepted rate. – Ofir A. Nov 03 '12 at 13:38

2 Answers2

1

Take a look at my answer in this thread.

Let me know if you are still having problems.

cheers!

Community
  • 1
  • 1
PinoyCoder
  • 1,112
  • 8
  • 13
  • HI, Stjom, thanks for reply. where should i place ur code.. when to call it???... as soon as i delete from list how to do??? – Naruto Nov 03 '12 at 14:10
  • You can call this anywhere in your thread or as soon as you delete an item in your list. – PinoyCoder Nov 04 '12 at 21:29
0

Use AsynkTask for Custom ListView Like this:-

 InboxTask.execute(); will call asynktask

class InboxTask extends AsyncTask<Uri, Integer, ArrayList<InboxField>> 
{
@Override
    protected void onPreExecute() 
   {
     pd=ProgressDialog.show(HomePage.this, "", "Please wail...",true,false);
    super.onPreExecute();
   }
@Override
    protected ArrayList<InboxField> doInBackground(Uri... params) 
    {
return ArrayList<InboxField>
}
  @Override
    protected void onPostExecute(ArrayList<InboxField> result) 
    {
        inboxAdapter=new InboxAdapter(HomePage.this,result);
        list.setAdapter(inboxAdapter);
                      adapter.notifyDataSetChanged();
            list.destroyDrawingCache();
        pd.dismiss();

    }

put adepter.notigyDataSetChanged in onPostExecute Method

Deepanker Chaudhary
  • 1,694
  • 3
  • 15
  • 35