[#106][안드로이드] Custom Alert Dialog 만들기 (색상 변경)
[안드로이드] Custom Alert Dialog 만들기 (색상 변경)
1. style.xml에 스타일 지정 (MyAlertDialogStyle)
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:alertDialogTheme">@style/MyAlertDialogStyle</item>
</style>
<style name="MyAlertDialogStyle" parent="@style/Theme.AppCompat.Dialog.Alert">
<item name="android:textColor">@color/white</item>
<item name="android:typeface">monospace</item>
<item name="android:background">@color/maincolor</item>
</style>
</resources>
| cs |
2. AlertDialog만들기
private void makeDialog(){
AlertDialog.Builder alt_bld = new AlertDialog.Builder(BrandAuth.this, R.style.MyAlertDialogStyle);
alt_bld.setTitle("인증 요청").setIcon(R.drawable.check_dialog_64)
.setMessage("입력하신 정보로 브랜드 인증을 요청합니다.\n사실과 일치하지 않을 시 삭제조치 될 수 있습니다.").setCancelable(
false).setPositiveButton("네",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// 네 클릭
// 현재 로그인한 사용자의 Uid
String cu = mAuth.getUid();
// 작성한 클래스정보를 RegClassData에 담기
BrandAuthData regClassData = new BrandAuthData(brand_name.getText().toString(), brand_web.getText().toString(), brand_phone.getText().toString(),
spinner_field.getSelectedItem().toString(), brand_address_content.getText().toString());
// DB에 등록
mDatabase.child("Regclass").child(cu).setValue(regClassData);
// 등록완료 알림창 발생
makeConfirmDialog();
}
}).setNegativeButton("아니오",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// 아니오 클릭. dialog 닫기.
dialog.cancel();
}
});
AlertDialog alert = alt_bld.create();
alert.show();
}
| cs |
3. 결과물



댓글
댓글 쓰기