Android studio 安卓工作室可以';t更换按钮';AlertDialog JAVA的颜色

Android studio 安卓工作室可以';t更换按钮';AlertDialog JAVA的颜色,android-studio,android-alertdialog,Android Studio,Android Alertdialog,我无法更改按钮的文本颜色,我尝试了stackoverflow上找到的所有解决方案,但什么都没有 import androidx.appcompat.app.AlertDialog; AlertDialog.Builder doubleDishConfirm = new AlertDialog.Builder(AggiungiPiattoAttivity.this, R.style.MyAlertDialogStyle); doubleDishConfirm.setPositiveButton

我无法更改按钮的文本颜色,我尝试了stackoverflow上找到的所有解决方案,但什么都没有

import androidx.appcompat.app.AlertDialog;

AlertDialog.Builder doubleDishConfirm = new AlertDialog.Builder(AggiungiPiattoAttivity.this, R.style.MyAlertDialogStyle);

doubleDishConfirm.setPositiveButton( ... ) 
doubleDishConfirm.setNegativeButton( ... )

doubleDishConfirm.show();
我的MyAlertDialogStyle(在themes.xml中)是:


@android:彩色/黑色
@android:彩色/黑色
@android:彩色/白色
我做过的其他测试也有评论,我也试过Coloracent,但什么都没有

import androidx.appcompat.app.AlertDialog;

AlertDialog.Builder doubleDishConfirm = new AlertDialog.Builder(AggiungiPiattoAttivity.this, R.style.MyAlertDialogStyle);

doubleDishConfirm.setPositiveButton( ... ) 
doubleDishConfirm.setNegativeButton( ... )

doubleDishConfirm.show();
它改变了背景的颜色,文字“try1”和“try2”,但按钮的文字变得不可见


使用以下内容设置themes.xml文件中的项目textColor

<item name="android:textColor">@color/tab_background_light_pink</item>

关于第一点:我没有styles.xml,但是有themes.xml,我尝试在那里使用它,但是它给了我错误,无论如何,在colors.xml中是这样的。对于第二个:dialog无法fina名为setOnShowListener的方法,它说:无法解析“DialogInterface”中的方法“setOnShowListener”,嗨,不要放入
dialog.setOnShowListener
;我所说的
dialog
是指您的
AlertDialog
的名称,即
doubleDishConfirm
。另外,对于第一个错误,尝试使用textColor,看看会发生什么。是的,我使用了我的对话框名。我创建了对话框,然后我创建了dialog.SetOnShowListener,但对话框中没有此方法…您好,我回去检查了您的代码,注意到您已经创建了一个生成器,但实际上还没有创建AlertDialog。此外,还必须在AlertDialog builder上调用.create()。在实际的AlertDialog上调用.show()。
dialog.setOnShowListener( new OnShowListener() {
    @Override
    public void onShow(DialogInterface arg0) {
        dialog.getButton(AlertDialog.(//id of your button)).setTextColor(//whichever color you want);
    }
});