• Attempt to write to field 'android.support.v4.app.FragmentManagerImpl android.support.v4.app.Fragment.mFragmentManager' on a null object reference


    E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: org.example.magnusluca.drawertestapp, PID: 3624
    java.lang.NullPointerException: Attempt to write to field 'android.support.v4.app.FragmentManagerImpl android.support.v4.app.Fragment.mFragmentManager' on a null object reference
    没修改前代码:

    public class OrderManagerFragmentPagerAdapter extends FragmentPagerAdapter {
            private FollowingResult.DataEntity.CountEntity countEntity;
    
    
            public OrderManagerFragmentPagerAdapter(FragmentManager fm, FollowingResult.DataEntity.CountEntity countEntity) {
                super(fm);
                this.countEntity = countEntity;
            }
    
    
            @Override
            public void destroyItem(ViewGroup container, int position, Object object) {
                //super.destroyItem(container, position, object);
            }
    
    
            @Override public Fragment getItem(int position) {
                OrderManagerFragment badgeRefreshListener = OrderManagerFragment
                    .this;
                String strTabTitle = TITLES[position];
                switch (strTabTitle) {
                    case "新订单":
                        return NewOrderFragment.newInstance(badgeRefreshListener);
                    case "跟踪中":
                        return NewOrderFragment.newInstance(badgeRefreshListener);
                    case "转出":
                        return NewOrderFragment.newInstance(badgeRefreshListener);
                    case "成交":
                        return NewOrderFragment.newInstance(badgeRefreshListener);
                    case "流失":
                        return NewOrderFragment.newInstance(badgeRefreshListener);
                    case "无效":
                        return NewOrderFragment.newInstance(badgeRefreshListener);
                    default:
                        return null;
                }
            }
    
    
            @Override public CharSequence getPageTitle(int position) {
                return TITLES[position % TITLES.length];
            }
    
    
            @Override public int getCount() {
                return TITLES.length;
            }
        }
     

    出问题主要出现在标红的地方,代码修改过为

    return new NewOrderFragment();
    问题解决

    stackoverflow上面解决方案:http://stackoverflow.com/questions/26822516/how-to-display-3-fragments-inside-pageviewer

  • 相关阅读:
    4.数据库表相关操作
    2.快速创建springboot项目 连pom文件里面的配置都不用配了
    1.开始Springboot 基本配置和helloworld
    mysql 对数据库操作的常用sql语句
    mysql简单操作
    1.开始Spring
    关于java中的异常
    关于maven
    npm相关知识点
    git源代码管理工具操作步骤
  • 原文地址:https://www.cnblogs.com/androidsuperman/p/5754288.html
Copyright © 2020-2023  润新知