android - Redrawing EditText after changing InputType -


i have made class responsible monitoring edittext widget following observer pattern. sole function disable or re-enable auto-correct based on method call. able achieve this, problem new inputtype applies new text add edittext - old text still retains red underline show can auto-corrected.

is there way can force new inputtype apply entire edittext block, , not new content add? tried calling edittext.invalidate() , edittext.refreshdrawablestate() in hope text refresh, no avail.

final class spellcheckerobserver implements edittextobserver {      public static final int key = keygenerator.generateuniqueid();      private int defaultinputtype;      spellcheckerobserver(edittextsubject subject) {         subject.attach(spellcheckerobserver.key, this);     }      @override     public void activating(edittext edittext) {          defaultinputtype = edittext.getinputtype();            edittext.setrawinputtype(inputtype.type_text_flag_no_suggestions);      }      @override     public void deactivating(edittext edittext) {         edittext.setinputtype(defaultinputtype);     }  } 

i found out answer whilst looking through source code textview, came across removesuggestionspans() method.i wasn't aware suggestions in fact type of span, (unsurprisingly, suggestionspan)

this meant able remove red underline following code:

suggestionspan[] spans = edittext.gettext().getspans(         0, edittext.length(), suggestionspan.class );  if (spans.length > 0) {     (suggestionspan span : spans) {         edittext.gettext().removespan(span);     } } 

Comments

Popular posts from this blog

Capture and play voice with Asterisk ARI -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -

visual studio - Installing Packages through Nuget - "Central Directory corrupt" -