Giter VIP home page Giter VIP logo

Comments (5)

ongakuer avatar ongakuer commented on August 16, 2024

Sorry,This lib is not design for dynamic viewpager at first.

I think maybe It will work like this:

mPagerAdapter.add(object);
mPagerAdapter.notifyDataSetChanged(); 
mViewPager.setCurrentItem(mPagerAdapter.getCount()-1, false);  // set the current item to the wanted position
mPagerIndicator.setViewPager(mViewPager); // re-create Indicators

At setViewPager method, we can get mCurrentPosition , and selected current position.

from circleindicator.

HappyDr0id avatar HappyDr0id commented on August 16, 2024

I tried your proposition, but if I don't set the ViewPager before changing the current item, it will crash. This is certainly because the indicator don't have the new positions yet.

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setBackgroundResource(int)' on a null object reference
at me.relex.circleindicator.CircleIndicator.onPageSelected(CircleIndicator.java:162)
at android.support.v4.view.ViewPager.dispatchOnPageSelected(ViewPager.java:1792)

I will try to make a "dynamic viewpager"-ready version of CircleIndicator :)

Thanks for your answer !

from circleindicator.

APBrown avatar APBrown commented on August 16, 2024

@HappyDr0id Does this PR fix your issue? #28

from circleindicator.

HappyDr0id avatar HappyDr0id commented on August 16, 2024

Well, this pull request seems to be okay for me.
I am sorry but I actually don't have the time to test this PR for my case. I will let the quick fix I was talking about earlier in this issue, in the actual project I am working on.

from circleindicator.

drac94 avatar drac94 commented on August 16, 2024

I had the same problem, this was the solution #21

from circleindicator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.