Skip to content Skip to sidebar Skip to footer

How To Refresh A Fragment In Android

I am using three tabs and these tabs having list view, on these tabs i am adding new list items in tabs. After Creating a list the new list item is not added when i scroll the tabs

Solution 1:

when you add item in listview call one method (make it by own) in your adapter

 public void refreshWishlistAdapter() {
    itemList.clear();
    itemList.addAll(dbHelper.getallWishlistItems());
    itemsAdapter.notifyDataSetChanged();
}

Solution 2:

Fragmentfrg=null;
frg = getSupportFragmentManager().findFragmentByTag("Your_Fragment_TAG");
finalFragmentTransactionft= getSupportFragmentManager().beginTransaction();
ft.detach(frg);
ft.attach(frg);
ft.commit();

Your_Fragment_TAG is the name you gave your fragment when you created it

This code is for support library.

Post a Comment for "How To Refresh A Fragment In Android"