Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto-correction does not work with autocompletetextview?

It seems like there is no way to enable auto-correction with the autocompletetextview and the multiautocompletetextview in Android.

  1. Auto-correction works perfectly with the standard EditText.
  2. As soon as an Autocompletetextview or a Multiautocompletetextview is used, auto-correction ceases to work.

I've already tried a bunch of potential workarounds but none of them is working (i.e. using the various input options in the XML file).

Has anyone been able to successfully enable auto-correction on an Autocompletetextview or a Multiautocompletetextview and still be able to feed a list of suggestion to it as an Adapter? Thanks much!

like image 362
Joseph Lam Avatar asked Jan 08 '23 00:01

Joseph Lam


1 Answers

autocompletetextview will set InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE flag on the input view.

That flag make some IME stop giving auto correct suggestions.

You can extend AutoCompleteTextView and remove the flag like below

public SocialCompleteTextView(Context context) {
    super(context);
    int removed = this.getInputType() & (this.getInputType() ^ InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
    this.setInputType(removed);
}
like image 135
ksc91u Avatar answered Jan 10 '23 13:01

ksc91u