This is how I added a library to myself:

compile ('com.github.florent37:materialviewpager:1.2.0@aar'){ transitive = true } 

I added everything I needed, everything works well. I want to add my own implementation of one method of this library. I just wanted to inherit my class from the source and override the method there. Inherited, override it in any way, because the original class uses a different class in which I need to override the method. And this class, in which the method needs to be redefined, is taken from the main class like this:

 public PagerSlidingTabStrip getPagerTitleStrip() { return (PagerSlidingTabStrip) pagerTitleStripContainer.findViewById(R.id.materialviewpager_pagerTitleStrip); } 

And the pagerTitleStripContainer variable in this class is private and there is no access to it. And there is no get method either. Yes, and no set .

Maybe there are some ways to implement the method? Help me please. You need to override the method:

 private void addTab(final int position, CharSequence title, View tabView) 

Which is in the class PagerSlidingTabStrip

  • Alternatively, you can clone your git-repository github.com/florent37/MaterialViewPager , edit and rebuild, and if you think it is necessary for everyone, then pull-request - Sergi
  • 2
    Reflection API to help - katso
  • If all you need is to get access to a private variable, then the easiest way will probably be to use Reflection Api, as suggested above. If you add code and describe what needs to be done, I can write a method. - Kirill Stoianov

0