
Custom AlertView Dialogue
The most advanced Android dialogue library.
Custom AlertView Dialogue includes simple message popups, confirmation alerts, selector popups, action sheet bottom menus, and input/feedback contact forms. This library fixes many issues and crashes that plague other alert dialogue libraries and looks amazing while doing so!
Custom AlertView Dialogue is part of the Custom UI collection of beautiful, minimalistic, and customizable Android UI components.

About
Android alert dialogues are bland, limited in functionality, and visually inconsistent across Android versions. Existing Android dialogue libraries often crashed and were hard to customize. CustomAlertDialogue was created to offer a beautiful alert dialogue with advanced capabilities. Here at Codelessly, we're building a Flutter website/app builder, development tools, and UI templates to increase productivity. If that sounds interesting, you'll want to subscribe to updates below 😎
CustomAlertViewDialogue is licensed under Zero-Clause BSD and released as Emailware. If you like this project or it helped you, please subscribe to updates. Although it is not required, you might miss the goodies we share!

Import
Add this library to build.gradle.
repositories {
maven { url 'https://jitpack.io' }
}
implementation 'com.github.searchy2:CustomAlertViewDialogue:latest-version'
Usage
Custom AlertView Dialogue uses the Builder format to initialize an alert view programmatically. To display an simple alert message, just drag and drop the following code into your project. It's that easy!

CustomAlertDialogue.Builder alert = new CustomAlertDialogue.Builder(MainActivity.this)
.setStyle(CustomAlertDialogue.Style.DIALOGUE)
.setTitle("Custom Alert")
.setMessage("This is a long description to test the dialogue's text wrapping functionality")
.setNegativeText("OK")
.setOnNegativeClicked(new CustomAlertDialogue.OnNegativeClicked() {
@Override
public void OnClick(View view, Dialog dialog) {
dialog.dismiss();
}
})
.setDecorView(getWindow().getDecorView())
.build();
alert.show();
IMPORTANT: The Dialog Fragment is extremely picky about the Activity passed into the builder. If the improper Activity is passed, the dialogue will crash! Here's how to pass the proper Activity in the following cases:
- Activity - construct with
ClassName.this
- Fragment - construct with
getActivity()
- ViewHolder - construct with
getActivity().getApplicationContext()
Do not attempt to construct the dialogue with getContext(). The Builder requires an Activity and passing a Context does not work!
Hint: Passing the DecorView to the Dialogue Builder in setDecorView will create a nice blurred background. Here's how to pass the correct DecorView:
- Activity - use
getWindow().getDecorView()
- Fragment - use
getActivity().getWindow().getDecorView()
- Viewholder - use
((Activity) mContext).getWindow().getDecorView()
Examples
Custom AlertView Dialogue provides many customization methods to display the alerts you need.
Simple Alert - a simple popup message.

CustomAlertDialogue.Builder alert = new CustomAlertDialogue.Builder(MainActivity.this)
.setStyle(CustomAlertDialogue.Style.DIALOGUE)
.setTitle("Custom Alert")
.setMessage("This is a long description to test the dialogue's text wrapping functionality")
.setNegativeText("OK")
.setNegativeColor(R.color.negative)
.setNegativeTypeface(Typeface.DEFAULT_BOLD)
.setOnNegativeClicked(new CustomAlertDialogue.OnNegativeClicked() {
@Override
public void OnClick(View view, Dialog dialog) {
dialog.dismiss();
}
})
.setDecorView(getWindow().getDecorView())
.build();
alert.show();
Confirmation Alert - a popup dialogue with two customizable choices.

CustomAlertDialogue.Builder alert = new CustomAlertDialogue.Builder(MainActivity.this)
.setStyle(CustomAlertDialogue.Style.DIALOGUE)
.setCancelable(false)
.setTitle("Delete Items")
.setMessage("Delete all completed items?")
.setPositiveText("Confirm")
.setPositiveColor(R.color.negative)
.setPositiveTypeface(Typeface.DEFAULT_BOLD)
.setOnPositiveClicked(new CustomAlertDialogue.OnPositiveClicked() {
@Override
public void OnClick(View view, Dialog dialog) {
dialog.dismiss();
Toast.makeText(mContext, "Items Deleted", Toast.LENGTH_SHORT).show();
}
})
.setNegativeText("Cancel")
.setNegativeColor(R.color.positive)
.setOnNegativeClicked(new CustomAlertDialogue.OnNegativeClicked() {
@Override
public void OnClick(View view, Dialog dialog) {
dialog.dismiss();
}
})
.setDecorView(getWindow().getDecorView())
.build();
alert.show();
Selector - a scrollable list of options.

ArrayList<String> destructive = new ArrayList<>();
destructive.add("Choice 1");
ArrayList<String> other = new ArrayList<>();
other.add("Choice 2");
other.add("Choice 3");
other.add("Choice 4");
other.add("Choice 5");
other.add("Choice 6");
other.add("Choice 7");
other.add("Choice 8");
other.add("Choice 9");
other.add("Choice 10");
other.add("Choice 11");
other.add("Choice 12");
other.add("Choice 13");
other.add("Choice 14");
other.add("Choice 15");
other.add("Choice 16");
other.add("Choice 17");
other.add("Choice 18");
other.add("Choice 19");
other.add("Choice 20");
CustomAlertDialogue.Builder alert = new CustomAlertDialogue.Builder(MainActivity.this)
.setStyle(CustomAlertDialogue.Style.SELECTOR)
.setDestructive(destructive)
.setOthers(other)
.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
CustomAlertDialogue.getInstance().dismiss();
Toast.makeText(mContext, "Selected " + i, Toast.LENGTH_SHORT).show();
}
})
.setDecorView(getWindow().getDecorView())
.build();
alert.show();
Action Sheet - a highly customizable bottom menu.

ArrayList<String> other = new ArrayList<String>();
other.add("Copy");
other.add("Forward");
CustomAlertDialogue.Builder alert = new CustomAlertDialogue.Builder(MainActivity.this)
.setStyle(CustomAlertDialogue.Style.ACTIONSHEET)
.setTitle("Action Sheet")
.setTitleColor(R.color.text_default)
.setCancelText("More...")
.setOnCancelClicked(new CustomAlertDialogue.OnCancelClicked() {
@Override
public void OnClick(View view, Dialog dialog) {
Vibrator vibe = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
vibe.vibrate(10);
dialog.dismiss();
Handler handler = new Handler();
Runnable r = new Runnable() {
public void run() {
MoreSelector();
}
};
handler.postDelayed(r, 50);
}
})
.setOthers(other)
.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
String selection = adapterView.getItemAtPosition(i).toString();
Vibrator vibe = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
vibe.vibrate(10);
switch (selection)
{
case "Copy":
CustomAlertDialogue.getInstance().dismiss();
Toast.makeText(mContext, "Copied", Toast.LENGTH_SHORT).show();
break;
case "Forward":
CustomAlertDialogue.getInstance().dismiss();
Toast.makeText(mContext, "Forwarded", Toast.LENGTH_SHORT).show();
break;
}
}
})
.setDecorView(getWindow().getDecorView())
.build();
alert.show();
Input Box - helps collect user input. Can be used as a contact/feedback form.

ArrayList<String> lineHint = new ArrayList<>();
lineHint.add("Username");
lineHint.add("Email Address");
lineHint.add("Name");
lineHint.add("Zip Code");
ArrayList<String> lineText = new ArrayList<>();
lineText.add("sampleuser");
lineText.add(null);
lineText.add("Sample User");
ArrayList<String> boxHint = new ArrayList<>();
boxHint.add("Message");
ArrayList<String> boxText = new ArrayList<>();
boxText.add("BoxText");
CustomAlertDialogue.Builder alert = new CustomAlertDialogue.Builder(MainActivity.this)
.setStyle(CustomAlertDialogue.Style.INPUT)
.setTitle("Submit Feedback")
.setMessage("We love to hear feedback! Please share your thoughts and comments:")
.setPositiveText("Submit")
.setPositiveColor(R.color.positive)
.setPositiveTypeface(Typeface.DEFAULT_BOLD)
.setOnInputClicked(new CustomAlertDialogue.OnInputClicked() {
@Override
public void OnClick(View view, Dialog dialog, ArrayList<String> inputList) {
Toast.makeText(mContext, "Sent", Toast.LENGTH_SHORT).show();
for (String input : inputList)
{
Log.d("Input", input);
}
dialog.dismiss();
}
})
.setNegativeText("Cancel")
.setNegativeColor(R.color.negative)
.setOnNegativeClicked(new CustomAlertDialogue.OnNegativeClicked() {
@Override
public void OnClick(View view, Dialog dialog) {
dialog.dismiss();
}
})
.setLineInputHint(lineHint)
.setLineInputText(lineText)
.setBoxInputHint(boxHint)
.setBoxInputText(boxText)
.setDecorView(getWindow().getDecorView())
.build();
alert.show();
Customization
Override Fullscreen
By default, showing an alert dialogue enters fullscreen mode. This behavior can be disabled by overriding the dialogue's style.
Place the following code in your project's style.xml to override the dialogue's style and disable fullscreen mode.
<!-- Override AlertView Dialogue Fullscreen -->
<style name="CustomDialog" parent="android:Theme.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:backgroundDimAmount">0.5</item>
<item name="android:windowIsFloating">false</item>
<item name="android:gravity">center</item>
</style>
Builder Attributes
| Attribute |
Description |
| setStyle(Style style) |
Set AlertView type DIALOGUE ACTIONSHEET SELECTOR INPUT |
| setTitle(String title) |
set AlertView title text |
| setMessage(String message) |
setMessage(String message) |
| setPositiveText(String positiveButtonText) |
set Confirmation Alert right button text |
| set Confirmation Alert right button text |
set Confirmation Alert right button text |
| set Confirmation Alert right button text |
set Action Sheet cancel button text |
| setTitleColor(int titleColor) |
set title text color |
| setMessageColor(int messageColor) |
set message text color |
| setPositiveColor(int positiveTextColor) |
set positive button text color |
| setNegativeColor(int negativeColor) |
set negative button text color |
| setCancelColor(int cancelColor) |
set cancel button text color |
| set cancel button text color |
set title text font. Must pass the path to the font in the assets folder |
| setMessageFont(String bodyFontPath) |
set message text font. Must pass the path to the font in the assets folder |