Android: Snackbar da ArrayIndexOutOfBoundsException

el código que parece dar la excepción es el siguiente:

Snackbar.make(findViewById(R.id.content_main), "E' necessario abilitare il GPS per aggiornare la lista", Snackbar.LENGTH_INDEFINITE) .setAction("ATTIVA", new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(intent); } }).show(); 

Lo digo porque intenté depurar la aplicación y sólo funciona eliminando esta parte del código.

Aquí está el registro de errores:

 E/AndroidRuntime: FATAL EXCEPTION: main Process: dgmovida, PID: 22151 java.lang.IndexOutOfBoundsException: Invalid index 3, size is 3 at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255) at java.util.ArrayList.get(ArrayList.java:308) at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:848) at android.view.View.layout(View.java:17938) at android.view.ViewGroup.layout(ViewGroup.java:5812) at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1197) at android.view.View.layout(View.java:17938) at android.view.ViewGroup.layout(ViewGroup.java:5812) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344) at android.widget.FrameLayout.onLayout(FrameLayout.java:281) at android.view.View.layout(View.java:17938) at android.view.ViewGroup.layout(ViewGroup.java:5812) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585) at android.widget.LinearLayout.onLayout(LinearLayout.java:1494) at android.view.View.layout(View.java:17938) at android.view.ViewGroup.layout(ViewGroup.java:5812) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344) at android.widget.FrameLayout.onLayout(FrameLayout.java:281) at android.view.View.layout(View.java:17938) at android.view.ViewGroup.layout(ViewGroup.java:5812) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585) at android.widget.LinearLayout.onLayout(LinearLayout.java:1494) at android.view.View.layout(View.java:17938) at android.view.ViewGroup.layout(ViewGroup.java:5812) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344) at android.widget.FrameLayout.onLayout(FrameLayout.java:281) at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:3193) at android.view.View.layout(View.java:17938) at android.view.ViewGroup.layout(ViewGroup.java:5812) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2666) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2367) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1437) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7403) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:920) at android.view.Choreographer.doCallbacks(Choreographer.java:695) at android.view.Choreographer.doFrame(Choreographer.java:631) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:906) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7229) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 

Los únicos momentos en que utilizo un ArrayList son cuando lo inicializo:

 ArrayList<CustomLVArray> retrievedData; ListAdapter listAdapter; ListView listView; .... @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); .... retrievedData = new ArrayList<>(); listView = (ListView) findViewById(R.id.content_main); listAdapter = new CustomListViewAdapter(this, retrievedData); listView.setAdapter(listAdapter); listView.setOnScrollListener.... 

y cuando le agrego cosas:

 CustomLVArray message = new CustomLVArray("Title", "subtitle", "Lorem ipsum dolor sit amet ipsum dolor sit amet ipsum dolor sit amet ipsum dolor sit amet", getResources().getDrawable(R.drawable.ic_menu_camera)); retrievedData.clear(); for (int i = 0; i <= 10; i++) { retrievedData.add(message); } 

FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.