AlertDialog for Android, a beautiful and material alert dialog to use in your android app.

Overview

Alert Dialog API Known Vulnerabilities Android Arsenal License

AlertDialog for Android, a beautiful and material alert dialog to use in your android app.

Older verion of this library has been removed please use new version of this library.

And Don't Forget To Follow Me On Instagram

Follow me on instagram to stay up-to-date https://instagram.com/akshay_sunil_masram

Contributors

NassB (Nassim B.)

Library available at JitPack.io

Latest version of this library is migrated to androidx

ScreenShot

Setup

The simplest way to use AlertDialog is to add the library as dependency to your build.

Gradle

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

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

Step 2. Add the dependency

dependencies {
        implementation 'com.github.TutorialsAndroid:KAlertDialog:v14.0.19'
}

Usage

Show material progress

KAlertDialog pDialog = new KAlertDialog(this, KAlertDialog.PROGRESS_TYPE);
pDialog.getProgressHelper().setBarColor(Color.parseColor("#A5DC86"));
pDialog.setTitleText("Loading");
pDialog.setCancelable(false);
pDialog.show();

You can customize progress bar dynamically with materialish-progress methods via KAlertDialog.getProgressHelper():

  • resetCount()
  • isSpinning()
  • spin()
  • stopSpinning()
  • getProgress()
  • setProgress(float progress)
  • setInstantProgress(float progress)
  • getCircleRadius()
  • setCircleRadius(int circleRadius)
  • getBarWidth()
  • setBarWidth(int barWidth)
  • getBarColor()
  • setBarColor(int barColor)
  • getRimWidth()
  • setRimWidth(int rimWidth)
  • getRimColor()
  • setRimColor(int rimColor)
  • getSpinSpeed()
  • setSpinSpeed(float spinSpeed)

A basic message:

new KAlertDialog(this)
    .setTitleText("Here's a message!")
    .show();

A title with a text under:

new KAlertDialog(this)
    .setTitleText("Here's a message!")
    .setContentText("It's pretty, isn't it?")
    .show();

A error message:

new KAlertDialog(this, KAlertDialog.ERROR_TYPE)
    .setTitleText("Oops...")
    .setContentText("Something went wrong!")
    .show();

A warning message:

new KAlertDialog(this, KAlertDialog.WARNING_TYPE)
    .setTitleText("Are you sure?")
    .setContentText("Won't be able to recover this file!")
    .setConfirmText("Yes,delete it!")
    .show();

A success message:

new KAlertDialog(this, KAlertDialog.SUCCESS_TYPE)
    .setTitleText("Good job!")
    .setContentText("You clicked the button!")
    .show();

A message with a custom icon:

new KAlertDialog(this, KAlertDialog.CUSTOM_IMAGE_TYPE)
    .setTitleText("Sweet!")
    .setContentText("Here's a custom image.")
    .setCustomImage(R.drawable.custom_img)
    .show();

To Hide Cancel And Confirm Button:

new KAlertDialog(this, KAlertDialog.CUSTOM_IMAGE_TYPE)
    .setTitleText("Sweet!")
    .setContentText("Here's a custom image.")
    .setCustomImage(R.drawable.custom_img)
    .setConfirmText("OK") //Do not call this if you don't want to show confirm button
    .setCancelText("CANCEL")//Do not call this if you don't want to show cancel button
    .show();

Bind the listener to confirm button:

new KAlertDialog(this, KAlertDialog.WARNING_TYPE)
    .setTitleText("Are you sure?")
    .setContentText("Won't be able to recover this file!")
    .setConfirmText("Yes,delete it!")
    .setConfirmClickListener(new KAlertDialog.KAlertClickListener() {
        @Override
        public void onClick(KAlertDialog sDialog) {
            sDialog.dismissWithAnimation();
        }
    })
    .show();

Show the cancel button and bind listener to it:

new KAlertDialog(this, KAlertDialog.WARNING_TYPE)
    .setTitleText("Are you sure?")
    .setContentText("Won't be able to recover this file!")
    .setCancelText("No,cancel plx!")
    .setConfirmText("Yes,delete it!")
    .showCancelButton(true)
    .setCancelClickListener(new KAlertDialog.KAlertClickListener() {
        @Override
        public void onClick(KAlertDialog sDialog) {
            sDialog.cancel();
        }
    })
    .show();

Customizing the alert dialog

Title


Description here

") //you can use html in title text //This is how you can set dark theme to alert dialog box @Override protected void onCreate(Bundle savedInstanceState) { //sets the theme for app SharedPreferences sharedPreferences = this .getSharedPreferences("theme", Context.MODE_PRIVATE); final boolean dark = sharedPreferences.getBoolean("dark", false); setTheme(dark ? R.style.AppThemeDark : R.style.AppTheme); DARK_STYLE = dark; //this will apply dark theme to KAlertDialog Box super.onCreate(savedInstanceState); setContentView(R.layout.main_ui); } ">
.confirmButtonColor(R.color.colorPrimary) // you can change the color of confirm button
.cancelButtonColor(R.color.colorAccent) // you can change the color of cancel button
.setContentTextSize(50) // you can change the content text size
.setTitleText("

Title


Description here

") //you can use html in title text //This is how you can set dark theme to alert dialog box @Override protected void onCreate(Bundle savedInstanceState) { //sets the theme for app SharedPreferences sharedPreferences = this .getSharedPreferences("theme", Context.MODE_PRIVATE); final boolean dark = sharedPreferences.getBoolean("dark", false); setTheme(dark ? R.style.AppThemeDark : R.style.AppTheme); DARK_STYLE = dark; //this will apply dark theme to KAlertDialog Box super.onCreate(savedInstanceState); setContentView(R.layout.main_ui); }

And if you want to change the button corners with color create a drawable file

">
    
    
   
        
    
            
     
                
      
                
      
            
     
        
    
        
    
            
     
                
      
                
      
            
     
        
    
    
   

And then call this method when you create drawable

  .confirmButtonColor(R.drawable.button_background) // you can change border and color of button

And if you want to hide Title Text and Content Text of alert dialog

.setTitleText("Are you sure?") //just don't write this line if you want to hide title text
.setContentText("Won't be able to recover this file!") // don't write this line if you want to hide content text

Change the dialog style upon confirming:

new KAlertDialog(this, KAlertDialog.WARNING_TYPE)
    .setTitleText("Are you sure?")
    .setContentText("Won't be able to recover this file!")
    .setConfirmText("Yes,delete it!")
    .setConfirmClickListener(new KAlertDialog.KAlertClickListener() {
        @Override
        public void onClick(KAlertDialog sDialog) {
            sDialog
                .setTitleText("Deleted!")
                .setContentText("Your imaginary file has been deleted!")
                .setConfirmText("OK")
                .setConfirmClickListener(null)
                .changeAlertType(KAlertDialog.SUCCESS_TYPE);
        }
    })
    .show();

License

Copyright 2019 KAlertDialog

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
       
Comments
  • New feature: set background color of confirm and cancel buttons

    New feature: set background color of confirm and cancel buttons

    Hey,

    Is it possible to add a method to set the background color of the confirm and cancel buttons? This way the library is more usefull to include in project and it doesn't break the style of the application.

    Kind regard, Thomas

    opened by thomasvc 4
  • Custom text color and text font

    Custom text color and text font

    Hello, Great library! I am using it in my project with over 2mil+ downloads.

    It would be great to be able to set the text color and the text font "out of the box" with a method like .setTitleTextFont(TypeFace), but until then, alternatively there is another way to do this if anyone else is interested:

     KAlertDialog kAlertDialog = new KAlertDialog(VideoActivity.this)
                        .setTitleText("MyTitle")
                        .setContentText("MyContent")
                        .setConfirmText("Sure")
                        .setCancelText("No thanks");
    
      kAlertDialog.show();
    
    Typeface typeFace= ResourcesCompat.getFont(VideoActivity.this, R.font.myTypeFace);
    
    // For Title
    TextView titleText = kAlertDialog.getWindow().findViewById(R.id.title_text);
    titleText.setTextColor(getResources().getColor(R.color.black));
    titleText.setTypeface(leagueSpartan);
    
    // For Content
    TextView contentText = kAlertDialog.getWindow().findViewById(R.id.content_text);
    
    // For Confirm Button
    TextView confirmButton = kAlertDialog.getWindow().findViewById(R.id.custom_confirm_button);
    
    // For Cancel Button
    TextView cancelButton = kAlertDialog.getWindow().findViewById(R.id.cancel_button);
    

    That's it!

    opened by moisoni97 2
  • Hide title when is empty.

    Hide title when is empty.

    hi, most of messages dont need a title. message like "do you want to move this?" not really need a title like "warning!". when we set title as empty "" , title textview can sets to gone for a better looking dialog. thanks.

    opened by mehdico 2
  • NoClassDefFoundError: Failed resolution of: Landroid/webkit/TracingController;

    NoClassDefFoundError: Failed resolution of: Landroid/webkit/TracingController;

    KAlertDialog: v19.0.19 Device API 26

    Compile SDk 32 Gradle Version 7.3.3 Gradle Plugin 7.2.1 Kotlin 1.6.10

    Log: I/zygote: Rejecting re-init on previously-failed class java.lang.Class: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/webkit/TracingController; I/zygote: at java.lang.Class java.lang.Class.classForName(java.lang.String, boolean, java.lang.ClassLoader) (Class.java:-2) I/zygote: at java.lang.Class java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (Class.java:453) I/zygote: at java.lang.Class android.webkit.WebViewFactory.getWebViewProviderClass(java.lang.ClassLoader) (WebViewFactory.java:150) I/zygote: at java.lang.Class android.webkit.WebViewFactory.getProviderClass() (WebViewFactory.java:417) I/zygote: at android.webkit.WebViewFactoryProvider android.webkit.WebViewFactory.getProvider() (WebViewFactory.java:211) I/zygote: at android.webkit.WebViewFactoryProvider android.webkit.WebView.getFactory() (WebView.java:2467) I/zygote: at java.lang.String android.webkit.WebView.findAddress(java.lang.String) (WebView.java:1738) I/zygote: at void android.text.util.Linkify.gatherMapLinks(java.util.ArrayList, android.text.Spannable) (Linkify.java:550) I/zygote: at boolean android.text.util.Linkify.addLinks(android.text.Spannable, int) (Linkify.java:253) I/zygote: at void android.widget.TextView.setText(java.lang.CharSequence, android.widget.TextView$BufferType, boolean, int) (TextView.java:5328) I/zygote: at void android.widget.TextView.setText(java.lang.CharSequence, android.widget.TextView$BufferType) (TextView.java:5248) I/zygote: at void android.widget.TextView.setText(java.lang.CharSequence) (TextView.java:5205) I/zygote: at com.developer.kalert.KAlertDialog com.developer.kalert.KAlertDialog.setContentText(java.lang.String) (KAlertDialog.java:380) I/zygote: at void com.developer.kalert.KAlertDialog.onCreate(android.os.Bundle) (KAlertDialog.java:135) I/zygote: at void android.app.Dialog.dispatchOnCreate(android.os.Bundle) (Dialog.java:403) I/zygote: at void android.app.Dialog.show() (Dialog.java:302)

    opened by murdak 1
  • Not working when minifyEnabled True in Gradle

    Not working when minifyEnabled True in Gradle

    App crashes when compiled with minifyEnable = true

    I added does not obfuscate KalertDialog in proguard-rules in order to use minify and be able to use my application

    opened by mariodantas 1
  • problem with android manifests because constraint layout is upper than 1.3

    problem with android manifests because constraint layout is upper than 1.3

    Hi, guys, your library is beautiful but also has a small problem your preview library has also this problem your library isn't matched with constraint layout 2 but it works fine with 1.3 please solve this problem thank you

    opened by RahimpourDeveloper 1
  • New Logo Proposal

    New Logo Proposal

    Hi... Just Came across your project and I really like it, I am a Logo/Icon Designer who really has the passion and loves to contribute to very nice open source projects, I want to create and Propose a new Logo/Icon for your project that will represent what your project is all about.

    Currently working on a few Idea Concept, I will share it here All For Free once I am done creating it, so you can give your feedback on any changes or adjustments you might want to suit your needs.

    Your response would be really appreciated...

    Regards!

    opened by chimzycash 1
  • Hidden Navigation Bar not working after dismiss dialog

    Hidden Navigation Bar not working after dismiss dialog

    Hi.

    I add these to my fragments and activities to enable full screen and hide navigation bar

    view.setSystemUiVisibility(
                  View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                          | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                          | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                          | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                          | View.SYSTEM_UI_FLAG_FULLSCREEN
                          | View.SYSTEM_UI_FLAG_IMMERSIVE);
    
    view.setOnSystemUiVisibilityChangeListener(
                  new View.OnSystemUiVisibilityChangeListener() {
                      @Override
                      public void onSystemUiVisibilityChange(int visibility) {
                          if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
                              view.setSystemUiVisibility(
                                      View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                                              | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                                              | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                                              | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
                                              | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                                              | View.SYSTEM_UI_FLAG_IMMERSIVE);
                          }
                      }
                  });
    

    But somehow after dialog dismiss, if I swipe up from the bottom, the navigation bar will show and never hidden anymore. I'm not sure is this because of the behavior of the kAlertDialog or my code problem.

    opened by leonlee0116 0
  • How can i display keyboard when i use editText

    How can i display keyboard when i use editText

    	KAlertDialog pDialog = new KAlertDialog(this, KAlertDialog.SUCCESS_TYPE);
    	pDialog.setCustomView(EditText.ID);
    

    HI

    i want to know how to display the keyboard when i touch the editText view

    can someone help me?

    opened by CT-1326 0
  • Add dialog with an edit text | add compileOptions 1.8 to handle lambda

    Add dialog with an edit text | add compileOptions 1.8 to handle lambda

    Dialog with EditText available Change AlertDialog to Dialog for the keyboard Add compileOptions in build.gradle to use lamda Reformat code with Android Studio Reformat File tool

    opened by NassB 0
Releases(v20.3.7)
Owner
Akshay Masram
📱 Android Developer 🖥️ Coding Enthusiastic
Akshay Masram
AlertDialog - Explain about Alert Dialog in Android

AndroidTemplate I got a problem to create Android project with Java 11 and anoth

Monthira Chayabanjonglerd 1 Feb 13, 2022
ionalert 1.3 1.6 Java Sweetalert, Dialog, Alert Dialog

ionalert - Android Alert Dialog A beautiful design Android Alert Dialog, alternative of Sweet Alert Dialog based on KAlertDialog using MaterialCompone

Excel Dwi Oktavianto 23 Sep 17, 2022
SweetAlert for Android, a beautiful and clever alert dialog

Sweet Alert Dialog SweetAlert for Android, a beautiful and clever alert dialog 中文版 Inspired by JavaScript SweetAlert Demo Download ScreenShot Setup Th

书呆子 7.3k Dec 30, 2022
Make your native android Dialog Fancy and Gify. A library that takes the standard Android Dialog to the next level with a variety of styling options and Gif's. Style your dialog from code.

FancyGifDialog-Android Prerequisites Add this in your root build.gradle file (not your module build.gradle file): allprojects { repositories { ...

Shashank Singhal 522 Jan 2, 2023
Android has a built in microphone through which you can capture audio and store it , or play it in your phone. There are many ways to do that but with this dialog you can do all thats with only one dialog.

# Media Recorder Dialog ![](https://img.shields.io/badge/Platform-Android-brightgreen.svg) ![](https://img.shields.io/badge/Android-CustomView-blue.sv

Abdullah Alhazmy 73 Nov 29, 2022
An beautiful and easy to use dialog library for Android

An beautiful and easy to use dialog library for Android

ShouHeng 22 Nov 8, 2022
Android AlertDialog with moving dots progress indicator

Spots progress dialog Android AlertDialog with moving spots progress indicator packed as android library. =========== Usage The library available in m

Maksym Dybarskyi 1.1k Jan 8, 2023
GenericDialog 1.3 0.0 Java A new AlertDialog for Android is here...!!

GenericDialog A new AlertDialog for Android is here...!! Getting Started Installation Add this into your root build.gradle file: allprojects { reposi

Jaidev Naik 22 Sep 6, 2022
Android AlertDialog with moving dots progress indicator

Spots progress dialog Android AlertDialog with moving spots progress indicator packed as android library. =========== Usage The library available in m

Maksym Dybarskyi 1.1k Jan 8, 2023
[Deprecated] This project can make it easy to theme and custom Android's dialog. Also provides Holo and Material themes for old devices.

Deprecated Please use android.support.v7.app.AlertDialog of support-v7. AlertDialogPro Why AlertDialogPro? Theming Android's AlertDialog is not an eas

Feng Dai 468 Nov 10, 2022
⭐ ‎‎‎‏‏‎ ‎Offers a range of beautiful sheets (dialogs & bottom sheets) for quick use in your project. Includes many ways to customize sheets.

Sheets Sleek dialogs and bottom-sheets for quick use in your app. Choose one of the available sheets or build custom sheets on top of the existing fun

Maximilian Keppeler 838 Dec 30, 2022
CuteDialog- Android Custom Material Dialog Library

A Custom Material Design Dialog Library for Android Purpose CuteDialog is a Highly Customizable Material Design Android Library. CuteDialog allows dev

CuteLibs - Smart & Beautiful Android Libraries 7 Dec 7, 2022
A Material Dialog Builder for Jetpack Compose

Compose Material Dialogs ?? Easy to use library to help you build complex dialogs using Jetpack Compose ?? Current Library Compose Version: 1.1.1 See

Pranav Maganti 433 Dec 31, 2022
An easy to use, yet very customizable search dialog

search-dialog An awesome and customizable search dialog with built-in search options. Usage First add jitpack to your projects build.gradle file allpr

Mad Mirrajabi 518 Dec 15, 2022
Extremely useful library to validate EditText inputs whether by using just the validator for your custom view or using library's extremely resizable & customisable dialog

Extremely useful library for validating EditText inputs whether by using just the validator (OtpinVerification) for your custom view or using library's extremely resizable & customisable dialog (OtpinDialogCreator)

Ehma Ugbogo 17 Oct 25, 2022
Android library to show "Rate this app" dialog

Android-RateThisApp Android-RateThisApp is an library to show "Rate this app" dialog. The library monitors the following status How many times is the

Keisuke Kobayashi 553 Nov 23, 2022
An Android library for displaying a dialog where it presents new features in the app.

WhatIsNewDialog What is new dialog for Android is used for presenting new features in the the app. It can be used in the activity starts, from menu or

NonZeroApps 22 Aug 23, 2022
Android library to show "Rate this app" dialog

Android-RateThisApp Android-RateThisApp is an library to show "Rate this app" dialog. The library monitors the following status How many times is the

Keisuke Kobayashi 553 Nov 23, 2022
Advanced dialog solution for android

DialogPlus Simple and advanced dialog solution. Uses normal view as dialog Provides expandable option Multiple positioning Built-in options for easy i

Orhan Obut 5k Dec 29, 2022