I know there are a tonne of answers on SO for this but I can't seem to get it working how I'd like. I have a SherlockFragment
containing a ListView
which is populated by some data retrieving from a file. I've added a refresh button to the Fragment, the idea being that when you press it it retrieves any changes in the file and adds them to the view if necessary. I also added the popular PullToRefresh library.
Unfortunately, nothing changes however when I reload the Fragment (for example, rotating the device) I can see the new data. I've read about notifyDataSetChanged()
but it isn't working for me. The only thing I've gotten working is calling mPager.notifyDataSetChanged()
from my main FragmentActivity class and having the following set in my ViewPager adapter:
@Override
public int getItemPosition(Object object) {
return POSITION_NONE;
}
This accomplishes what I want, but it's not very sleek about it, and you can see it forcing the reload as it were. I'm currently using PullToRefresh and it forces it off page abruptly and quite frankly it just looks bad. To put it bluntly I need to call onCreateView
of my Fragment from my AsyncTask reloading the data.
If needed I'll post code, there's just a lot of it so I wouldn't want to post anything unneeded.
Oh, and please note I tried notifyDataSetChanged()
in the onPostExecute()
of my task.
Thanks for any guidance.