Fatal Error AFTER text change listener executed
SOLVED
I have an开发者_运维技巧 app that searches through an arraylist whenever the search string is updated in an EditText. I have a text change listener added to the EditText. It usually works but randomly I've been getting a Fatal error with no reference to a line number in my app (I'm Using Eclipse Logcat) I've put log outputs in my code to find the last line that is executed. Unexpectedly this turned out to be AFTER the text change listener had executed all it's code, and presumably after the thread had been handed back to the UI? I'd be grateful of any help.
Here's the full code in my text Listener. I'm getting the log output saying it Finished this function though. So where does the thread go after this?
public void afterTextChanged(Editable s) {
if (("" + inputField.getText()).length() > 0) {
fullSearchString += ("" + inputField.getText()).trim();
inputField.setText("");
searchArray(fullSearchString);
out("FINISHED Text change Listener");
}
}
Here's the stack trace
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): FATAL EXCEPTION: main
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): at java.util.ArrayList.get(ArrayList.java:311)
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): at android.widget.TextView.sendAfterTextChanged(TextView.java:6194)
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): at android.widget.TextView$ChangeWatcher.afterTextChanged(TextView.java:6377)
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): at android.text.SpannableStringBuilder.sendTextHasChanged(SpannableStringBuilder.java:897)
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): at android.text.SpannableStringBuilder.change(SpannableStringBuilder.java:353)
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): at android.text.SpannableStringBuilder.change(SpannableStringBuilder.java:269)
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:432)
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:409)
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:28)
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:583)
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): at android.view.inputmethod.BaseInputConnection.commitText(BaseInputConnection.java:174)
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): at com.android.internal.widget.EditableInputConnection.commitText(EditableInputConnection.java:120)
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:257)
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:77)
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): at android.os.Handler.dispatchMessage(Handler.java:99)
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): at android.os.Looper.loop(Looper.java:123)
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): at android.app.ActivityThread.main(ActivityThread.java:4627)
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): at java.lang.reflect.Method.invokeNative(Native Method)
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): at java.lang.reflect.Method.invoke(Method.java:521)
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:871)
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
09-21 13:05:24.146: ERROR/AndroidRuntime(7660): at dalvik.system.NativeStart.main(Native Method)
精彩评论