【发布时间】:2012-11-20 03:48:35
【问题描述】:
我有以下布局(实际上是空的):
<?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>
Activity 类包含以下内容:
public class TestActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
}
}
当我在移动设备上运行此程序时,我收到以下错误:
SpannableStringBuilder
SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
我在有和没有 TextView 的情况下都试过了,但错误仍然存在,我一定是在做一些根本性的错误,这样一个基本的布局才会导致这种情况。
有没有人知道如何在没有错误的情况下加载它?
【问题讨论】:
-
检查 LogCat 并查看与您的错误相关的堆栈跟踪。如果确实来自此应用程序,请将整个堆栈跟踪作为对您问题的编辑发布。另外,我会从
LinearLayout中删除android:contentDescription,因为该容器不可聚焦,因此不会使用AFAIK 的描述。 -
感谢您的回复。不幸的是,这个错误没有堆栈跟踪,输出与我上面发布的完全一样,但 LogCat 中的应用程序字段确实指向我的应用程序。我已经调试了代码并逐行执行了每一行,没有抛出任何错误,所以它一定是在 Android 代码中的某个地方,它期望一些不存在的东西。
-
我也想知道如何避免这个恼人的错误,而不需要为最终用户删除/禁用任何功能。
-
我将手机重置为出厂设置,但在尝试了“三星键盘修复”后它消失了,这似乎对我没有用...
-
也许这根本不是问题,但是在升级到 Android 4.1.1 之后,我在日志中看到了很多类似这样的错误。 SPAN_EXCLUSIVE_EXCLUSIVE 跨度的长度不能为零