private void disableSpellingSuggestions ( boolean disable ) { // toggling suggestions often resets the cursor location, but we don't want that to happen int start = mMentionsEditText . getSelectionStart ( ) ; int end = mMentionsEditText . getSelectionEnd ( ) ; // -1 means there is no selection or cursor. if ( start == - 1 || end == - 1 ) { return ; } if ( disable ) { // store the previous input type mOriginalInputType = mMentionsEditText . getInputType ( ) ; } mMentionsEditText . setRawInputType ( disable ? InputType . TYPE_TEXT_FLAG_NO_SUGGESTIONS : mOriginalInputType ) ; mMentionsEditText . setSelection ( start , end ) ; }
Disables spelling suggestions from the user s keyboard . This is necessary because some keyboards will replace the input text with spelling suggestions automatically which changes the suggestion results . This results in a confusing user experience .