Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayIndexOutOfBounds Exception #155

Open
Harshkanani opened this issue Dec 14, 2021 · 0 comments
Open

ArrayIndexOutOfBounds Exception #155

Harshkanani opened this issue Dec 14, 2021 · 0 comments

Comments

@Harshkanani
Copy link

Harshkanani commented Dec 14, 2021

My Code :
ArrayList<NavigationTabBar.Model> models = new ArrayList<>();
final String[] colors = mFloatingView.getResources().getStringArray(R.array.vertical_ntb);

    models.add(new NavigationTabBar.Model.Builder(AppCompatResources.getDrawable(mFloatingView.getContext(), R.drawable.vector_player), Color.parseColor(colors[0])).title("Player").build());
    models.add(new NavigationTabBar.Model.Builder(AppCompatResources.getDrawable(mFloatingView.getContext(), R.drawable.vector_item), Color.parseColor(colors[1])).title("Items").build());
    models.add(new NavigationTabBar.Model.Builder(AppCompatResources.getDrawable(mFloatingView.getContext(), R.drawable.vector_vehicle), Color.parseColor(colors[2])).title("Vehicles").build());
    models.add(new NavigationTabBar.Model.Builder(AppCompatResources.getDrawable(mFloatingView.getContext(), R.drawable.vector_injector), Color.parseColor(colors[4])).title("Injector").build());
    models.add(new NavigationTabBar.Model.Builder(AppCompatResources.getDrawable(mFloatingView.getContext(), R.drawable.vector_esp_settings), Color.parseColor(colors[3])).title("Aimbot").build());
    if(!models.isEmpty())
            header_tabbar.setModels(models);

    viewpager.setPageTransformer(false, new CubeInTransformer());
    viewpager.setAdapter(new MyPagerAdapter(getApplicationContext()));
    viewpager.setOffscreenPageLimit(5);
    header_tabbar.setViewPager(viewpager, 0);

Error Log :
Fatal Exception: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.get(ArrayList.java:437)
at androidx.viewpager.widget.ViewPager.fakeDragBy(ViewPager.java:2603)
at devlight.io.library.ntb.NavigationTabBar.setModelIndex(NavigationTabBar.java:873)
at devlight.io.library.ntb.NavigationTabBar$10.run(NavigationTabBar.java:1649)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7562)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

Note : I am using PagerAdapter in a service with a viewpager

I am unable to understand why does this error occured. Please help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant