我有以下布局(实际上是空的):

<?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和错误仍然存在,我一定是做了根本性的错误为这样一个基本的布局,导致这一点。

有人有什么想法吗,我怎么才能让这个加载没有错误?


当前回答

Masood Moshref是对的,这个错误发生是因为菜单的选项菜单没有做好准备,在onCreate()方法中缺少“返回super.onCreateOptionsMenu(菜单)”。

其他回答

尝试使用默认的Android键盘,它会消失

Masood Moshref是对的,这个错误发生是因为菜单的选项菜单没有做好准备,在onCreate()方法中缺少“返回super.onCreateOptionsMenu(菜单)”。

尝试调试这个错误,首先到你的android终端/控制台并执行这个命令:

ps | grep THE_ERROR_PID_YOU_GET_(IT_IS_A_NUMBER)

然后如果输出是你的app…是你的应用程序导致了错误。尝试寻找传递到布局中的空字符串。

我有这个完全相同的问题,这是我的错误,因为我传递了一个空字符串到我的布局。把“”改成“”之后,这个错误就消失了。

如果你没有从控制台输出你的应用程序,那么它是其他东西导致的(可能,正如其他人所说,android键盘)

当我从网上复制一些文本时,我也遇到了这个问题。我的解决方案是在做任何进一步处理之前修剪文本/删除格式。

在你的安卓手机上转到: 设置->应用程序管理器->全部->三星键盘,然后点击“清除缓存” (删除此应用程序收集的所有数据)。