0

[这是我一直面临的问题,无法在黑暗模式下更改错误消息。]

如何编辑错误弹出窗口中文本的颜色。当主题和反馈为空并且用户尝试发送邮件时,我一直弹出错误消息。

public class FeedBack extends AppCompatActivity {

    EditText subject, body;
    Button send;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_feed_back);


        send = findViewById(R.id.sendFeedBT);
        subject = findViewById(R.id.subjectET);
        body = findViewById(R.id.bodyTextET);


        send.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {


                String subjectSTR = subject.getText().toString().trim();
                String bodySTR = body.getText().toString().trim();

                if(subjectSTR.isEmpty()){

                    subject.setError("Enter a Subject Please");
                    subject.requestFocus();
                }
                else if (bodySTR.isEmpty()){
                    body.setError("Enter the Message Please");
                    body.requestFocus();
                }

                else {

                    Intent email = new Intent(Intent.ACTION_SEND);
                    email.putExtra(Intent.EXTRA_EMAIL, new String[]{"example@gmail.com"});
                    email.putExtra(Intent.EXTRA_SUBJECT, subjectSTR);
                    email.putExtra(Intent.EXTRA_TEXT, bodySTR);
                    email.setType("message/rfc822");
                    startActivity(Intent.createChooser(email, "Choose an Email client :"));
                    finish();
                }
            }
        });
    }
}
4

2 回答 2

0

定义错误颜色 res/values/colors.xml

... ...
#000000 #002db3 ... ...

于 2019-12-05T05:20:04.937 回答
0

您需要创建一个自定义样式,例如:

<style name="error_text_style" parent="@android:style/TextAppearance">
    <item name="android:textColor">@color/error_color</item>
    <item name="android:textStyle">Italic</item>
</style>

然后设置这个样式。app:errorTextAppearance="@style/error_text_style"

于 2019-12-04T19:47:34.933 回答