setHintTextColor()中的EditText [英] setHintTextColor() in EditText

查看:1130
本文介绍了setHintTextColor()中的EditText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有查看,其中有两个文本框,用户可以选择通过对话框,在同一屏幕上的另一个观点的文字颜色。因此,当通过对话框,用户改变颜色,我改变了的EditText 全文及摘要的提示颜色。但是,当有一些文字是用的EditText 用户后选择其它颜色则该文本即将在颜色,但如果我删除所有文本,然后颜色的 HintText 快到previous颜色。比如现在我有红色的文本框现在用户选择绿色的颜色,以便文本有绿色的颜色,但如果我删除文本,然后提示文本来了红色,即使我的变化暗示颜色在$ C $℃。此问题只说到时,有一些文字出现。如果是空白的,并提示文本是有那么问题就不会来了。

I have View in which there is two text box and user can select text color from another view on the same screen through dialog box. So when user change color via dialog box i am changing color of EditText text and its hint. But when there is some text is available in EditText after that user select other color then that text is coming in that color but if i remove all that text then the color of HintText is coming previous color. For example now i have red color in text box now user select green color so text is there in green color but if i remove that text then hint text are coming in red even if i change hint color in code. This problem only comes when there is some text there. if it is blank and hint text is there then problem is not coming.

推荐答案

使用此选项可以更改提示的颜色。 -

Use this to change the hint color. -

editText.setHintTextColor(getResources().getColor(R.color.white));

解决您的问题 -

Solution for your problem -

editText.addTextChangedListener(new TextWatcher() {
    @Override
    public void onTextChanged(CharSequence arg0, int arg1, int arg2,int arg3){
        //do something
    }

    @Override
    public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
        //do something
    }

    @Override
    public void afterTextChanged(Editable arg0) {
        if(arg0.toString().length() <= 0) //check if length is equal to zero
            tv.setHintTextColor(getResources().getColor(R.color.white));
    }
});

这篇关于setHintTextColor()中的EditText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆