android-FlipView icon indicating copy to clipboard operation
android-FlipView copied to clipboard

FlipView Adapter not Updating

Open Kolokodess opened this issue 8 years ago • 1 comments

The adapter of a flipview is set onCreate. Everything works fine. The user is meant to select some items on another activity which would update the items on the flipview. I implemented this by changing the adapter of the flipView when onResume is called and the dismiss activity is the selectionActivity. The code is executed but it does not reflect on the flipView items.

What i do on onCreate

@Override 'public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); View rootView = inflater.inflate(R.layout.flip_main, container, false); mFlipView = (FlipView) rootView.findViewById(R.id.flip_view);

        mAdapter = new FlipAdapter(getActivity(),getHomeItems(), getFragmentManager());
        mAdapter.setCallback(this);
        mFlipView.setAdapter(mAdapter);
        mFlipView.setOnFlipListener(this);
        if (isFirstShown) {
            mFlipView.peakNext(false);
            isFirstShown = false;
        }
        mFlipView.setOverFlipMode(OverFlipMode.RUBBER_BAND);
        mFlipView.setEmptyView(getActivity().findViewById(R.id.empty_view));
        mFlipView.setOnOverFlipListener(this);
        return rootView;
    }

what is called after the user makes selection

FlipAdapterTest mAdapter = new FlipAdapterTest(getActivity(), getHomeItems(), getFragmentManager()); mFlipView.removeAllViews(); mFlipView.setAdapter(mAdapter);

Kolokodess avatar Jul 28 '15 14:07 Kolokodess

Is it possible that your fragment is being created again when your main activity resumes, such that onCreateView() is called and mFlipView is re-created? Can you post the code you use to create and add your fragment?

BTW, why are you calling super.onCreate() in onCreateView()? And, you don't need to call mFlipView.removeAllViews(), because it will be called in mFlipView.setAdapter().

ayltai avatar Jul 28 '15 15:07 ayltai