一般是使用 EditText的 setText()时参数传错了,比如setText(111),安卓把int类型的参数视为 view 的 id,结果找不到这个资源,导致异常崩溃。
正确使用方法 setText(”111“)
官网地址:
http://developer.android.com/reference/android/widget/TextView.html#setText(int)
public final void setText (char[] text, int start, int len)
Sets the TextView to display the specified slice of the specified char array. You must promise that you will not change the contents of the array except for right before another call to setText(), since the TextView has no way to know that the text has changed and that it needs to invalidate and re-layout.
public final void setText (CharSequence text)
Sets the string value of the TextView. TextView does not accept HTML-like formatting, which you can do with text strings in XML resource files. To style your strings, attach android.text.style.* objects to a SpannableString
, or see the Available Resource Types documentation for an example of setting formatted text in the XML resource file.