I'm using the common ActionBar - PullToRefresh library. The functionality works perfectly, but I have a customization where I edit some text, the progress bar color and the background color of the PullToRefresh.
In my fragment, all of this is achieved as such:
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ViewGroup viewGroup = (ViewGroup) view;
mPullToRefreshLayout = new PullToRefreshLayout(viewGroup.getContext());
ActionBarPullToRefresh.from(getActivity())
.insertLayoutInto(viewGroup)
.theseChildrenArePullable(getListView(), getListView().getEmptyView())
.listener(this)
.setup(mPullToRefreshLayout);
DefaultHeaderTransformer transformer = (DefaultHeaderTransformer) mPullToRefreshLayout
.getHeaderTransformer();
transformer.getHeaderView().findViewById(R.id.ptr_text)
.setBackgroundColor(getResources().getColor(R.color.black));
transformer.setProgressBarColor(getResources().getColor(R.color.blue));
transformer.setPullText("Pull down the internet...");
transformer.setRefreshingText("Finding posts...");
}
When you first use the app, everything looks perfect, but for some reason the background color, where in the code I did transformer.getHeaderView().findViewById(R.id.ptr_text).setBackgroundColor(getResources().getColor(R.color.black));, reverts back to what it is by default.
I have no idea why this is the case. I usually notice this after I haven't used the app in a while and I go back in and try to refresh something. I haven't pinned down any type of activity or action that causes it.
My best guess would be that sometimes, the HeaderView, which I get from the transformer via getHeaderView() hasn't been inflated yet. I thought it might have to do with the life cycle of the onViewCreated(View, Bundle) method in Fragments, but then the other customizations I did would also not work.
Is this a bug in the library? Am I not setting the background color properly?
0 comments:
Post a Comment