GithubHelp home page GithubHelp logo

Comments (3)

ogaclejapan avatar ogaclejapan commented on September 22, 2024 3

Hi, @GabiR
Sorry for replying late.

Maybe it will work with this code.

onCreate:

FragmentPagerItems pages = FragmentPagerItems.with(this)
    .add("Test1", Fragment1.class)
    .add("Test2", Fragment2.class)
    .add("Test3", Fragment3.class)
    .create();

FragmentStatePagerItemAdapter adapter = new FragmentStatePagerItemAdapter(
    getSupportFragmentManager(), pages) {
  @Override
  public int getItemPosition(Object object) {
    return PagerAdapter.POSITION_NONE;
  }
};

viewPager.setAdapter(adapter);
viewPagerTab.setViewPager(viewPager);

Replace:

pages.set(1, FragmentPagerItem.of("Test2", Fragment4.class));
adapter.notifyDataSetChanged();

If you want to also change the tab name, you will need to re-set the SmartTabLayout#setViewPager(...)

pages.set(1, FragmentPagerItem.of("Test2", Fragment4.class));
adapter.notifyDataSetChanged();
viewPagerTab.setViewPager(viewPager); 

Solved?

from smarttablayout.

GabiR avatar GabiR commented on September 22, 2024

Yup, thanks a lot

from smarttablayout.

MarkOSullivan94 avatar MarkOSullivan94 commented on September 22, 2024

@ogaclejapan would you be able to provide a working example of this? Trying to implement something similar and it changes the text within the tab but doesn't change the fragment displayed.

Update:

I tried adding the fragment within a new tab, seems like the issue is only for updating an existing tab.

from smarttablayout.

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.