Skip to content

mehrdadmmb2/MoAlertDialog--android-modern-dialog

Repository files navigation

What is this?

MoAlertDialog is a modern AlertDialog for Android. You need AppCompat 26.0.0 or later and min SDK 14 To use this library.

How to install?

Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
	...
		maven { url 'https://jitpack.io' }
	}
}

Add the dependency

dependencies {
	implementation 'com.github.mehrdadmmb2:MoAlertDialog:1.1.0'
}

How to use?

1- Initialize MoAlertDialog:

 MoAlertDialog dialog = new MoAlertDialog(context);

2- Show default Error or Success dialog:

dialog.showErrorDialog("Title", "Body");
dialog.showSuccessDialog("Title","Body");

3- After the use of one of the show methods, you can change all the dialog's options:

dialog.setDialogHeaderColor(int color)
dialog.setDialogBackgroundColor(int color)
dialog.setDialogButtonText(String text)
dialog.setDialogButtonBack(int backResource)
dialog.setDialogButtonTextColor(int color)
dialog.setDialogTitleTextColor(int color)
dialog.setDialogContentTextColor(int color)
dialog.setDilogIcon(int icon)
dialog.setDialogCancelable(boolean cancelable)
dialog.setDialogIconAnimation(Animation animation)
dialog.setTypeface(Typeface typeface)
dialog.setContentGravity(int gravity)
dialog.dismis()

Also you can set clickHandler on dialog's button;

dialog.setOnButtonClickListener(View.OnClickListener listener)