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

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

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


当前回答

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

其他回答

我遇到了同样的警告,发现删除一个未使用的@id可以消除警告。对我来说,这是显而易见的,因为@id与链接到数据库的textview的一个不断增长的列表相关联,所以每个条目都有一个警告。

尽量避免在XML设计中使用view。我也有同样的问题,但当我删除视图。它工作得很完美。

像例子:

             <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"                   
                android:hint="Username"
                android:inputType="number"                   
                android:textColor="#fff" />

            <view
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:background="#f9d7db" />

也检查并尝试通过反复试验改变android:inputType="number"到android:inputType="text"或最好不要使用它,如果不需要。有时键盘卡住,在一些设备中得到错误。

这对我很管用……在每个设备上

    <EditText
        android:maxLines="1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:textSize="15sp"
        android:layout_centerVertical="true"
        android:textColor="#000"
        android:id="@+id/input_search"
        android:background="@null"
        android:inputType="text"
        android:hint="Enter Address, City or Zip Code"
        android:imeOptions="actionSearch"
        />

在Java代码中:

mSearchText.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
            if(actionId == EditorInfo.IME_ACTION_SEARCH
                    || actionId == EditorInfo.IME_ACTION_DONE
                    || keyEvent.getAction() == KeyEvent.ACTION_DOWN
                    || keyEvent.getAction() == KeyEvent.KEYCODE_ENTER){

                //execute our method for searching
            }

            return false;
        }
    });

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

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

ps | grep THE_ERROR_PID_YOU_GET_(IT_IS_A_NUMBER)

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

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

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