Android 当我滑过最后一个选项卡时,是否加载第一个选项卡?

Android 当我滑过最后一个选项卡时,是否加载第一个选项卡?,android,actionbarsherlock,android-holo-everywhere,actionbarsherlock-map,Android,Actionbarsherlock,Android Holo Everywhere,Actionbarsherlock Map,最近,我使用holoeverywhere做了一些事情,但现在我面临一个问题,当我到达最后一个选项卡后一直向右滑动时,程序将加载第一个选项卡的视图,但没有更多选项卡,因此程序将崩溃。问题描述如下,我真的需要有人帮助我。 谢谢大家 以下是我的代码: public static class TabFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGrou

最近,我使用holoeverywhere做了一些事情,但现在我面临一个问题,当我到达最后一个选项卡后一直向右滑动时,程序将加载第一个选项卡的视图,但没有更多选项卡,因此程序将崩溃。问题描述如下,我真的需要有人帮助我。 谢谢大家

以下是我的代码:

public static class TabFragment extends Fragment {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        TextView textView = new TextView(getSupportActivity());
        textView.setText("Position: " + getArguments().getInt("position"));
        return textView;
    }
}

 private static Bundle make(int i) {
        Bundle bundle = new Bundle();
        bundle.putInt("position", i);
        return bundle;
    }

@Override
protected void onHandleTabs() {
    getSupportActionBar().removeAllTabs();
    for(int i = 0; i < 5; i++)
        addTab("Tab #" + i, TabFragment.class, make(i + 1));
}
我还使用了一些自定义设置:

getSupportActionBar().setCustomView(getLayoutInflater().inflate(R.layout.****,null));
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
View homeIcon = findViewById(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ? android.R.id.home : R.id.abs__home);
((View) homeIcon.getParent()).setVisibility(View.GONE);
这是:

getSupportActionBar().setDisplayUseLogoEnabled(false);
getSupportActionBar().setDisplayShowCustomEnabled(true);
下面是演示的代码,我不明白。在演示中,当我到达最后一个选项卡后向右移动时,程序将在屏幕右侧显示如下内容:

以下是演示的代码:

public static class TabFragment extends Fragment {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        Log.d("DemoTabsActivity", "test" + getArguments().getInt("position"));
        TextView textView = new TextView(getSupportActivity());
        textView.setText("Position: " + getArguments().getInt("position"));
        return textView;
    }
}

private static Bundle make(int i) {
    Bundle bundle = new Bundle();
    bundle.putInt("position", i);
    return bundle;
}

@Override
protected void onHandleTabs() {
    getSupportActionBar().removeAllTabs();
    for(int i = 0; i < 10; i++)
        addTab("Tab #" + i, TabFragment.class, make(i + 1));
    Log.d("TAG", "getSupportActionBar().getTabCount()" + getSupportActionBar().getTabCount());
}
公共静态类TabFragment扩展了Fragment{
@凌驾
创建视图上的公共视图(布局、充气机、视图组容器、,
Bundle savedInstanceState){
Log.d(“活动”、“测试”+getArguments().getInt(“位置”);
TextView TextView=新的TextView(getSupportActivity());
textView.setText(“位置:”+getArguments().getInt(“位置”));
返回文本视图;
}
}
专用静态包生成(int i){
Bundle=新Bundle();
bundle.putInt(“位置”,i);
返回包;
}
@凌驾
受保护的把手上的空隙(){
getSupportActionBar().removeAllTabs();
对于(int i=0;i<10;i++)
addTab(“Tab#”+i,TabFragment.class,make(i+1));
Log.d(“标记”、“getSupportActionBar().getTabCount()”+getSupportActionBar().getTabCount());
}

在代码中的某个地方,您试图访问/修改只有四个元素的数组的第五个元素。

我更新了上面演示的代码,几乎找不到区别。错误和问题保持不变,因此至少您现在知道在哪里查找错误。这一行似乎不那么容易
ActionBarImpl.java:989
public static class TabFragment extends Fragment {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        Log.d("DemoTabsActivity", "test" + getArguments().getInt("position"));
        TextView textView = new TextView(getSupportActivity());
        textView.setText("Position: " + getArguments().getInt("position"));
        return textView;
    }
}

private static Bundle make(int i) {
    Bundle bundle = new Bundle();
    bundle.putInt("position", i);
    return bundle;
}

@Override
protected void onHandleTabs() {
    getSupportActionBar().removeAllTabs();
    for(int i = 0; i < 10; i++)
        addTab("Tab #" + i, TabFragment.class, make(i + 1));
    Log.d("TAG", "getSupportActionBar().getTabCount()" + getSupportActionBar().getTabCount());
}
java.lang.IndexOutOfBoundsException: Invalid index 5, size is 5