. Advertisement .
..3..
. Advertisement .
..4..
I am new to java and searching the “e/spannablestringbuilder: span_exclusive_exclusive spans cannot have a zero length” to understand it better. It seems it doesn’t work as expected when I used some suggestions before. Here is the command line I use:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/set_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:contentDescription="content desc"
android:orientation="vertical" >
<TextView android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, I am a TextView" />
</LinearLayout>
public class TestActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
}
}
The error I’m getting is below:
SpannableStringBuilder
SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
Please give me the solution to this issue.
The cause:
After I research your problem, I find that you are testing on a Samsung mobile with TouchWiz, but it’s invalid. And you are giving an empty String to your layout. When you do not download your app from the output of console, the android keyboard causes it. These are the reasons of the error: ”e/spannablestringbuilder: span_exclusive_exclusive spans cannot have a zero length”.
Solution:
You can solve this error by testing on a Nexus S instead of a Samsung mobile. Nexus S is also manufactured by Samsung, but there is not TouchWiz in its Android OS.
Or you can try using Android keyboard, the error will disappear.
Another way is using
android:inputType="textNoSuggestions"
(orandroid:inputType="textEmailAddress|textNoSuggestions"
instead ofandroid:inputType="text"
.LogCat has given me the exact same error messages. It’s my 3rd-party keyboard that is causing it. The error message disappears when I switch it to Android keyboard.