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

After call notifyDataSetChanged() problem #2

Open
yick1993 opened this issue May 14, 2016 · 9 comments
Open

After call notifyDataSetChanged() problem #2

yick1993 opened this issue May 14, 2016 · 9 comments

Comments

@yick1993
Copy link

After call notifyDataSetChanged(), the scale of item will has some problem(e.g. even the item is not the center one, their scale will become 1.0f, as big as the center one ) but after scroll a little bit, it will become normal. So, any idea of this problem ? Thank you

@djshanne
Copy link

djshanne commented May 19, 2016

Hello,I had the same issue, the solution:

private void saveItem() { pagerAdapter.addItem(new Item("ItemAdded")); cardPager.setOffscreenPageLimit(pagerAdapter.getCount()); // this is the important thing cardPager.setCurrentItem(pagerAdapter.getCount()); // this is cos the problem still there when we add an item, but if you select the item inserted then the pager will show the new item added correctly }

@StephenVinouze
Copy link

Hi there!

Same issue here while removing item from my ViewPager (which calls notifyDataSetChanged()). I am currently using a library that wraps the ViewPager with additional features. When removing my item, the library takes care of updating the ViewPager content and scroll to next position. However both scale and margins are broken and only scrolling the content refreshes the pager correctly.

I tried to force an invalidate() that is done in the onPageScrolled() callback but with no success. I obviously tried the solution above but it is not always working. Plus this is not the wanted behavior as I definitely don't want to have my pager scrolling the last item.

Any idea how to simply achieve this force refresh to keep the CoverFlow correctly configured

@StephenVinouze
Copy link

Actually combining both setOffscreenPageLimit() setCurrentItem() seems to do the trick for all items except the first and last item in the pager, especially if you only want to scroll forward (after add item to pager) or back (after remove item from pager). Seems erratic to me :)

@RomiValladares
Copy link

RomiValladares commented Jun 19, 2016

I've stumbled with this issue too. Simulating a MotionEvent was the only thing that worked, though it obviously looks bad, and is prone to looking worse across devices.

@maximPetlyuk
Copy link

Confirm bug. Angle issue.

@catroom
Copy link

catroom commented Oct 26, 2016

@djshanne After call notifyDataSetChanged(),my view has no cos。event if i setOffscreenPageLimit,can you sovle it??

@djshanne
Copy link

Can you tell me, what do you mean with has no cos ? Sorry I dont get it. @catroom

@krunal3kapadiya
Copy link

I also have the same problem can anyone have a solution for it ?

@taeyoung4808
Copy link

taeyoung4808 commented Sep 8, 2017

same issue..

i use a trick this
pagerAdapter.notifyDataSetChanged(); viewPager.setAdapter(null); viewPager.setAdapter(pagerAdapter); viewPager.setCurrentItem(viewPosition);

i'm working

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

8 participants