Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 向滑动视图添加另一页_Android_Eclipse_View_Swipe - Fatal编程技术网

Android 向滑动视图添加另一页

Android 向滑动视图添加另一页,android,eclipse,view,swipe,Android,Eclipse,View,Swipe,我在玩弄滑动视图,我开始掌握窍门了 部分代码如下所示: @Override public Fragment getItem(int position) { Fragment fragment = new Fragment_1_Page_1(); switch(position){ case 0: fragment = new Fragment_1_Page_1(); break

我在玩弄滑动视图,我开始掌握窍门了

部分代码如下所示:

        @Override
    public Fragment getItem(int position) {
        Fragment fragment = new Fragment_1_Page_1();
        switch(position){
        case 0:
            fragment = new Fragment_1_Page_1();
            break;
        case 1:
            fragment = new Fragment_1_Page_2();
            break;
        case 2:
            fragment = new Fragment_1_Page_3();
            break;
        case 3:
            fragment = new Fragment_1_Page_4();
            break;

        }
        return fragment;
    }

    @Override
    public int getCount() {
        // Show 3 total pages.
        return 4;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        Locale l = Locale.getDefault();
        switch (position) {
        case 0:
            return getString(R.string.title_section1).toUpperCase(l);
        case 1:
            return getString(R.string.title_section2).toUpperCase(l);
        case 2:
            return getString(R.string.title_section3).toUpperCase(l);
        case 3:
            return getString(R.string.title_section4).toUpperCase(1);
        }
        return null;
    }
}
这里的问题是,当我添加第4个案例(案例3:,它扩展了Fragment_1_Page_4类)时,eclipse只会给我一个错误

我已将getCount()更改为返回4,而不是3。它给了我第四个页面,但eclipse在“getItem case 3:”和“getPageTitle case 3:”中给了我错误,他们说:“类型不匹配:无法从Fragment_1_page_4转换为Fragment”和“类型字符串中的方法toUpperCase(Locale)不适用于参数(int)”


所以我想在滑动到第四页时打开一个新视图。我真的希望你能帮助我

返回getString(R.string.title_section4.toUpperCase(1);问题是您在这里把1作为参数,而不是localeAh,非常感谢。一个小小的打字错误就够了。但它仍然给了我一个警告:“隐式使用默认语言环境是常见的bug来源:请改用toUpperCase(语言环境)”