tags:

views:

60

answers:

0

Hi, I'm relatively new to writing android apps and cant seem to get Linkify working with my EditText View.

I have a very simple application I'm using to try out some features, auto linking text. It's a single Activity with a single multiline EditText View. I have enabled Linkify in the main.xml (android:autoLink="all") so that any web, email or phone number entered in the EditText view gets linkified.

The issue I have is that after entering any text that should be linkified, i.e a web address, and then saving the text and exiting the app. When returning to the EditText I see the web address is now linkified but I cannot click on the EditText to enter more text as it will not give me a cursor anywhere but at the 1st position on the 1st line of the EditText. Then while clicking the screen trying to place a cursor at another line of text the app usually crashes.

These are the last few exceptions from the debug log:

java.lang.IndexOutOfBoundsException: getChars (-1 ... 0) starts before 0 android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:949) android.text.SpannableStringBuilder.getChars(SpannableStringBuilder.java:847) android.text.TextUtils.getChars(TextUtils.java:69) android.text.TextUtils.substring(TextUtils.java:255) android.view.inputmethod.BaseInputConnection.getTextAfterCursor(BaseInputConnection.java:339) com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:170)

If the EditText is changed to a TextView Linkfiy works fine. The problem seems to be trying to edit text while it's linkified.

Thanks.