Android EditText.setError() yields invisible error text

后端 未结 5 1218
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-08 21:17

I have a very simple EditText, as follows:



        
5条回答
  •  萌比男神i
    2020-12-08 21:48

    It looks like you can work around this problem by calling EditText.setError() with a SpannableStringBuilder object rather than a String.

    int ecolor = xxxx; // whatever color you want
    String estring = "Input is incorrect";
    ForegroundColorSpan fgcspan = new ForegroundColorSpan(ecolor);
    SpannableStringBuilder ssbuilder = new SpannableStringBuilder(estring);
    ssbuilder.setSpan(fgcspan, 0, estring.length(), 0);
    myedittext.setError(ssbuilder);
    

提交回复
热议问题