简体   繁体   中英

Crash when set TextView text

crash reporting catch two crashed after calling TextView.setText() with valid string (formated as "Session 16/09/2015 10:12")

on nexus7 with 5.0.2 and Galaxy S6 (SM-G925F) with 5.1.1 I cannot find steps to reproduce it

Android: 5.0.2 Manufacturer: asus Model: Nexus 7

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.text.method.WordIterator.setCharSequence(java.lang.CharSequence, int, int)' on a null object reference at android.widget.SpellChecker$SpellParser.parse(SpellChecker.java:559) at android.widget.SpellChecker$SpellParser.parse(SpellChecker.java:516) at android.widget.SpellChecker.spellCheck(SpellChecker.java:257) at android.widget.Editor.updateSpellCheckSpans(Editor.java:541) at android.widget.Editor.sendOnTextChanged(Editor.java:1017) at android.widget.TextView.sendOnTextChanged(TextView.java:7667) at android.widget.TextView.setText(TextView.java:4050) at android.widget.TextView.setText(TextView.java:3905) at android.widget.EditText.setText(EditText.java:85) at android.widget.TextView.setText(TextView.java:3880) ....my code that calls setText()

Does anybody seen something like this? Seems android crashes when try use spellchecker and show suggestions. I`m going to disable it with

android:inputType="textNoSuggestions"

May this help?

public boolean isSuggestionsEnabled ()

Added in API level 14 Return whether or not suggestions are enabled on this TextView. The suggestions are generated by the IME or by the spell checker as the user types. This is done by adding SuggestionSpans to the text. When suggestions are enabled (default), this list of suggestions will be displayed when the user asks for them on these parts of the text. This value depends on the inputType of this TextView. The class of the input type must be TYPE_CLASS_TEXT. In addition, the type variation must be one of TYPE_TEXT_VARIATION_NORMAL, TYPE_TEXT_VARIATION_EMAIL_SUBJECT, TYPE_TEXT_VARIATION_LONG_MESSAGE, TYPE_TEXT_VARIATION_SHORT_MESSAGE or TYPE_TEXT_VARIATION_WEB_EDIT_TEXT. And finally, the TYPE_TEXT_FLAG_NO_SUGGESTIONS flag must not be set.

Returns true if the suggestions popup window is enabled, based on the inputType.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM