prof_jack
prof_jack

Reputation: 2073

how to reflect changes in a calling activity in android?

I have a list view containing names.I am able to add those names to phones's contact list but the changes are not getting reflected in my list view untill I restart the application again.kindly help.thanks in advance. I have tried this but ain't working.

public void onPause(){
        super.onPause();
        finish();
    }

Upvotes: 0

Views: 190

Answers (3)

Hiral Vadodaria
Hiral Vadodaria

Reputation: 19250

Repopulate your listview in onResume() of your activity,so that changes will appear in your listview after you will add new data.

public void onResume(){
        super.onResume();
        populateListview();
}

public void populateListview()
{
    //reset adapter
    listview.setAdapter(adapter);
}

Upvotes: 0

Dinesh Prajapati
Dinesh Prajapati

Reputation: 9520

What you need to do in this case is whenever you add the list item you need to set the Adapter again. or you can call the notifyDatasetchanged() method.

Upvotes: 1

freshDroid
freshDroid

Reputation: 509

Try to do this.Hope this will solve your problem.

public void onPause(){
    super.onPause();
    Intent intent = getIntent();
    finish();
    startActivity(intent);        
}

Or

   //lv is your ListView
   lv.setAdapter(adapter);
   lv.invalidateViews();

after the contact list is updated.

Upvotes: 0

Related Questions