Giter VIP home page Giter VIP logo

Comments (8)

lyhgzx avatar lyhgzx commented on June 18, 2024

我也遇到这个问题,希望楼主找找原因,拜托了

from flycotablayout.

rw15250 avatar rw15250 commented on June 18, 2024

空指针一般都是生命周期的问题,fragment里可以放在onviewcreate初始化

from flycotablayout.

JakeWang123 avatar JakeWang123 commented on June 18, 2024

我也遇到这个问题,我的是fragment 里面通过SegmentTabLayout嵌套3个fragment,在第三个fragment里面点击一个按钮跳到另外一个activity 返回到 SegmentTabLayout 的第三个fragment 滑动报这个错误

from flycotablayout.

curiousleast avatar curiousleast commented on June 18, 2024

第一遍就没报,,敲第二遍就报

from flycotablayout.

MakeCodeFly avatar MakeCodeFly commented on June 18, 2024

我也遇到这个问题 请问各位怎么解决的

from flycotablayout.

VitaliBov avatar VitaliBov commented on June 18, 2024

You need to do a check:

private List<Fragment> tabs = new ArrayList<>();
private PagerAdapter pagerAdapter;

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment, container, false);
        initTabs();
        return view;
}

private void initTabs() {
        if (pagerAdapter == null) {
            pagerAdapter = new PagerAdapter(getChildFragmentManager());
        }
        if (tabs.isEmpty()) {
            tabs.add(FirstFragment.newInstance());
            tabs.add(SecondFragment.newInstance());
        }
        viewPager.setAdapter(pagerAdapter);
        tabLayout.setTabData(titles);
        tabLayout.setOnTabSelectListener(position -> viewPager.setCurrentItem(position));
        viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            }

            @Override
            public void onPageSelected(int position) {
                tabLayout.setCurrentTab(position);
            }

            @Override
            public void onPageScrollStateChanged(int state) {
            }
        });
}

from flycotablayout.

protectedMan avatar protectedMan commented on June 18, 2024

最后怎么解决的。。。

from flycotablayout.

Lee987 avatar Lee987 commented on June 18, 2024

mIndicatorAnimEnable为true时会执行calcOffset()方法,可以尝试设置mIndicatorAnimEnable为false绕过该方法。可以解决问题。但是希望有更好的方法解决

from flycotablayout.

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.