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

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

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


当前回答

明确您已经在mainactitivity中为以下方法onCreateOptionsMenu和onCreate传递了一个值

在某些情况下,开发人员删除“return super.onCreateOptionsMenu(menu)”语句并将其更改为“return true”。

其他回答

**DONT PUT SET TEXT IN TEXT WATCHER**etSearch.addTextChangedListener(object : TextWatcher {
        override fun afterTextChanged(s: Editable) {
            visibleResultList = false
            if (s.toString().length != 0) {
                getSearchSuggetion(no_of_rec, 0, s.toString())
            } else {
               // etSearch.setText("")
            }
            Log.e("text_change","============"+s.toString())
        }
        override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
        override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
        }
    })

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

检查是否有任何元素,如按钮或文本视图复制(复制两次)在屏幕上遇到。我没有注意到这件事,也不得不面对同样的问题。

我有同样的问题,但与listView....我解决了它,因为我使用了一个错误的R.id.listView列表视图需要有一个值,在我的情况下,它是字符串,我保存在listView2…所以正确的代码是R.id.listView2

在我的情况下,我点击最近的应用程序快捷方式在我的手机和关闭所有的应用程序。这个解决方案总是为我工作,因为这个错误与代码无关。