我的类中有以下onResume()函数,它扩展了AppCompatDialogFragment。 我只想在发生某种条件时才改变标题的颜色。我怎么能这样做?
public void onResume() {
super.onResume();
final AlertDialog dialog = (AlertDialog)getDialog();
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String code = editTextCode.getText().toString();
if(code.length() != 6 || !code.matches("[0-9A-F]+")){
dialog.setTitle("Insert a valid 6 digit hexcode");
//HERE I WANT TO CHANGE THE TITLE COLOR
// AND DO SOMETHING LIKE dialog.setTitleColor(...)
} else{
listener.applyHex(code);
dialog.dismiss();
}
}
});
}