Seems the refresh issue is discussed before, but none of the solutions worked for me.
What I am trying to do: I am using FragmentStatePagerAdapter. Each position of the adapter holds a fragment that has a linear layout that has chess like appearance, with each cell represented by a CheckedTextView.
And a listener that should listens for clicks and removes the previous selection on the cells and makes the new selection.
Whats working: Each fragment is loaded correctly with all the data/default states (calculated while the fragment is loaded in a list)
When I click a cell all the states from the saved cells list are fetched correctly and I can change see the state change in the code while debugging. At the same time I assign a new state for the CheckedTextView which represent a cell. This is set like:
CheckedTextView cellView = (CheckedTextView) GridRow.getChildAt(c);
cellView.setSelected(false);
cellView.setChecked(false);
cellView.setTag(cellsChess.get(i).get(c));
The Issue: Even though the values are stored and assigned correctly the view can't be refreshed the values of the cells in the view do not get updated.
Tips I have Tried that didn't worked: 1. Call adapter.notifyDataSetChanged: Can be called while using FragmentStatePagerAdapter only when we have overridden:
@Override
public int getItemPosition(Object object){
return POSITION_NONE;
}
2. Adding Overriden methods for DestroyItem and also adding the fragments to a Map on getItem:
This is not appropriate as I am working with FragmentStatePagerAdapter, so the whole purpose of using this pagerAdapter would be gone.
3. Calling invalidate: This is inappropriate for this scenario, I need realtime refresh.
4. setTag() method in instantiateItem(): I don't think this is appropriate in this situation.
Referenced threads: Refresh images on FragmentStatePagerAdapter on resuming activity
ViewPager PagerAdapter not updating the View
notifyDataSetChanged fails to update ListView
I have tried to state my issue as clear as possible, if anyone needs more clarification, do ask.
Urgent replies will be highly appreciated,
Cheers
****Update*****
I am using the ViewPagerIndicator, instead of the default ViewPager.