Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crashes when trying to load last page from first page before it has cycled through all the view #6

Open
varunrramani opened this issue Nov 10, 2015 · 1 comment

Comments

@varunrramani
Copy link

I have used the code of RecyclingPagerAdapter from android-demo/src/com/jakewharton/salvage/RecyclingPagerAdapter.java and RecyleBin from android-demo/src/com/jakewharton/salvage/RecycleBin.java but when I try to see the last page from first page before all the pages have been cycled through the app crashes.

@prakash1530
Copy link

Hi varunrramani This may be too late answer for you but may help others who have the same issue and have not resolved. i have also faced same issue, but solution is easy. open the file RcyclingPagerAdapter.java and go to method "instantiateItem(ViewGroup container, int position) " and add below line of code before "container.addView(view);"
if(view.getParent()!=null)
((ViewGroup)view.getParent()).removeView(view);
This will resolve the issue, Since when we try to see the last page from current page before all the pages have been cycled container already has the same view so it crashes saying remove the view or view already exist. so in the above code first if statement checks the view is present in parent or not if vie is there it removes the view ("((ViewGroup)view.getParent()).removeView(view);") from the parent and then adds it again. Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants