如何在警报对话框中更改EditText光标颜色?

时间:2019-05-29 10:45:35

标签: java android

我正在尝试更改“警报对话框”中EditText闪烁的光标颜色,因为这不是我想要的。颜色是蓝绿色,我要白色。我没有做任何改变。这就是我的意思 Alert Dialog With EditText](https://www.bing.com/images/search?view=detailV2&ccid=K1%2fOkkYC&id=7A70653842861A8EF4C2E3FA144B2E06F8A6253E&thid=OIP.K1_OkkYCaIu062eXXFNgjQAAAA&mediaurl=https%3a%2f%2fi.stack.imgur.com%2fKPKvQ.png&exph=193&expw=400&q=edittext+in+alertdialog+colors&simid=608013895961150146&selectedIndex=0)[![enter image description here] https://github.com/JeffreyWay/laravel-mix/blob/master/docs/options.md

这就是我所拥有的...

Java代码:

public void alertDialogWithText(){
    AlertDialog.Builder adb = new AlertDialog.Builder(new ContextThemeWrapper(MainActivity.this, R.style.EditTextAlertDialog));
    adb.setTitle("Title");
    inputET = new EditText(this);
    inputET.setInputType(InputType.TYPE_CLASS_TEXT);
    inputET.setTextColor(getResources().getColor(android.R.color.white));
    adb.setView(inputET);

    adb.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

        }
    });

    adb.show();
}

Colors.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#303030</color>
<color name="colorPrimaryDark">#000</color>
<color name="colorAccent">#fff</color>
</resources>

Styles.xml:

<style name="EditTextAlertDialog">
    <item name="android:textColor">@android:color/white</item>
    <item name="android:background">#444</item>
</style>

0 个答案:

没有答案