原生的dialog比较丑,需要设置dialog的字体颜色,框的背景颜色和button的颜色
AlertDialog dialog = new AlertDialog.Builder(this, AlertDialog.THEME_HOLO_LIGHT)
.setIcon(R.mipmap.info_commit_ok)
.setTitle(getResources().getString(R.string.info_commit_success))
.setMessage(R.string.register_result)
.setPositiveButton("确定", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
dialog.cancel();
startActivity(LoginActivity.class);
finish();
}
}).create();
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) { //
Button positiveButton = ((AlertDialog) dialog)
.getButton(AlertDialog.BUTTON_POSITIVE);
positiveButton.setBackgroundColor(getResources().getColor(R.color.main_color));
positiveButton.setTextColor(Color.WHITE);
}
});
dialog.show();