I have an app which loads a listview when opened, however I am getting an Array Index Out Of Bounds Exception, with no clues as to where the problem lies. It is trying to ac
Check your layouts and cursor column name array lengths in the CursorAdapter's constructor. When the two array's length mismatch, it causes ArrayOutOfBoundsException
.
your problem is in the getView method , this method will be called whenever u scroll through your array so make sure u check if the view is not null before doing any logic there.
This is caused by setting android:ellipsize="middle"
(or start
) on a TextView
that does not have android:singleLine="true"
on.
For example, the following crashes on this error:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="middle"
android:maxLines="1"
android:text="blahblahblahblahblahblahblahblahblahbla---go really long" />
But the following does not:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="middle"
android:singleLine="true"
android:text="blahblahblahblahblahblahblahblahblahbla---go really long" />
Reference: https://code.google.com/p/android/issues/detail?id=33868
Note: singleLine
is a deprecated attribute but still works on Jelly Bean.
This is definitely related to text view ellipsize logic, It has nothing to do with adapter code.