Note that there are some explanatory texts on larger screens.

plurals
  1. POHoloeverywhere tabs load the first one when I slide over the last tab?
    primarykey
    data
    text
    <p>Recently, I am using holoeverywhere to do something, but now I am facing a problem that when I keep sliding to right after reaching the last tab, the program will load the first tab's view but there is no more tabs, so the program will crash. The problem is described following and I really need someone to help me. Thanks to you all!</p> <p>The following is my Code:</p> <pre><code>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 &lt; 5; i++) addTab("Tab #" + i, TabFragment.class, make(i + 1)); } </code></pre> <p>The problem is that when I slide after the last tab, the view will like this:</p> <p><img src="https://i.stack.imgur.com/7OfuN.jpg" alt="enter image description here"></p> <p>and the program will crash with the following error:</p> <pre><code>05-05 21:33:26.258: E/AndroidRuntime(1573): FATAL EXCEPTION: main 05-05 21:33:26.258: E/AndroidRuntime(1573): java.lang.IndexOutOfBoundsException: Invalid index 5, size is 5 05-05 21:33:26.258: E/AndroidRuntime(1573): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251) 05-05 21:33:26.258: E/AndroidRuntime(1573): at java.util.ArrayList.get(ArrayList.java:304) 05-05 21:33:26.258: E/AndroidRuntime(1573): at com.android.internal.app.ActionBarImpl.getTabAt(ActionBarImpl.java:989) 05-05 21:33:26.258: E/AndroidRuntime(1573): at com.actionbarsherlock.internal.app.ActionBarWrapper.getTabAt(ActionBarWrapper.java:425) 05-05 21:33:26.258: E/AndroidRuntime(1573): at org.holoeverywhere.app.TabSwipeActivity.dispatchTabSelected(TabSwipeActivity.java:135) 05-05 21:33:26.258: E/AndroidRuntime(1573): at org.holoeverywhere.app.TabSwipeActivity.access$2(TabSwipeActivity.java:128) 05-05 21:33:26.258: E/AndroidRuntime(1573): at org.holoeverywhere.app.TabSwipeActivity$TabSwipeAdapter.onPageSelected(TabSwipeActivity.java:67) 05-05 21:33:26.258: E/AndroidRuntime(1573): at android.support.v4.view.ViewPager.scrollToItem(ViewPager.java:538) 05-05 21:33:26.258: E/AndroidRuntime(1573): at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:523) 05-05 21:33:26.258: E/AndroidRuntime(1573): at android.support.v4.view.ViewPager.onTouchEvent(ViewPager.java:1943) 05-05 21:33:26.258: E/AndroidRuntime(1573): at android.view.View.dispatchTouchEvent(View.java:5486) 05-05 21:33:26.258: E/AndroidRuntime(1573): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1953) 05-05 21:33:26.258: E/AndroidRuntime(1573): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1714) 05-05 21:33:26.258: E/AndroidRuntime(1573): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1959) 05-05 21:33:26.258: E/AndroidRuntime(1573): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1728) 05-05 21:33:26.258: E/AndroidRuntime(1573): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1959) 05-05 21:33:26.258: E/AndroidRuntime(1573): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1728) 05-05 21:33:26.258: E/AndroidRuntime(1573): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1959) 05-05 21:33:26.258: E/AndroidRuntime(1573): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1728) 05-05 21:33:26.258: E/AndroidRuntime(1573): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1959) 05-05 21:33:26.258: E/AndroidRuntime(1573): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1728) 05-05 21:33:26.258: E/AndroidRuntime(1573): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1959) 05-05 21:33:26.258: E/AndroidRuntime(1573): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1728) 05-05 21:33:26.258: E/AndroidRuntime(1573): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1892) 05-05 21:33:26.258: E/AndroidRuntime(1573): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1371) 05-05 21:33:26.258: E/AndroidRuntime(1573): at android.app.Activity.dispatchTouchEvent(Activity.java:2364) 05-05 21:33:26.258: E/AndroidRuntime(1573): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1840) 05-05 21:33:26.258: E/AndroidRuntime(1573): at android.view.View.dispatchPointerEvent(View.java:5662) 05-05 21:33:26.258: E/AndroidRuntime(1573): at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:2863) 05-05 21:33:26.258: E/AndroidRuntime(1573): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442) 05-05 21:33:26.258: E/AndroidRuntime(1573): at android.os.Handler.dispatchMessage(Handler.java:99) 05-05 21:33:26.258: E/AndroidRuntime(1573): at android.os.Looper.loop(Looper.java:137) 05-05 21:33:26.258: E/AndroidRuntime(1573): at android.app.ActivityThread.main(ActivityThread.java:4340) 05-05 21:33:26.258: E/AndroidRuntime(1573): at java.lang.reflect.Method.invokeNative(Native Method) 05-05 21:33:26.258: E/AndroidRuntime(1573): at java.lang.reflect.Method.invoke(Method.java:511) 05-05 21:33:26.258: E/AndroidRuntime(1573): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 05-05 21:33:26.258: E/AndroidRuntime(1573): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 05-05 21:33:26.258: E/AndroidRuntime(1573): at dalvik.system.NativeStart.main(Native Method) </code></pre> <p>and I also used some customized settings:</p> <pre><code>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 &gt;= Build.VERSION_CODES.HONEYCOMB ? android.R.id.home : R.id.abs__home); ((View) homeIcon.getParent()).setVisibility(View.GONE); </code></pre> <p>and this:</p> <pre><code>getSupportActionBar().setDisplayUseLogoEnabled(false); getSupportActionBar().setDisplayShowCustomEnabled(true); </code></pre> <p>The following is the demo's code and I just do not understand. In the demo, when I side to right after reaching the last tab, the program will show something at the right side of the screen like this:</p> <p><img src="https://i.stack.imgur.com/rujrW.jpg" alt="enter image description here"></p> <p>and these are the demo's code:</p> <pre><code>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 &lt; 10; i++) addTab("Tab #" + i, TabFragment.class, make(i + 1)); Log.d("TAG", "getSupportActionBar().getTabCount()" + getSupportActionBar().getTabCount()); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload