Giter Site home page Giter Site logo

alertdialog's Introduction

AlertDialog

API

Custom Alert Dialog with styles

AlertDialog with custom style

Prerequisites

Add this to your module's build.gradle file

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

Dependency

Add this to your module's build.gradle file

dependencies {
	        implementation 'com.github.yeyintkoko1788:AlertDialog:v1.0.0'
	}

How To Use

In your activity or fragment setup CustomAlertDialog This method always returns a AlertDialog object, so you can customize the Alert much more.

CustomAlertDialog dialog = new CustomAlertDialog(this, style);

For style parameter you can choose:

CustomAlertDialog.DialogStyle.DEFAULT
CustomAlertDialog.DialogStyle.NO_ACTION_BAR
CustomAlertDialog.DialogStyle.CURVE
CustomAlertDialog.DialogStyle.FILL_STYLE

More Style will come soon

DEFAULT

NO_ACTION_BAR

CURVE

FILL_STYLE

  • Use this methods to set Alert Title (except for FILL_STYLE alert) and Alert Message
  • dialog.setAlertTitle("Alert Title");
    dialog.setAlertMessage("Alert message...");
    
  • For Positive and Negative button use following method with onClickListener
  • dialog.setPositiveButton("Ok", new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Toast.makeText(getApplicationContext(),"Positive Button Clicked",Toast.LENGTH_SHORT).show();
                    dialog.dismiss();
                }
            });
            dialog.setNegativeButton("Cancel", new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Toast.makeText(getApplicationContext(),"Negative Button Clicked",Toast.LENGTH_SHORT).show();
                    dialog.cancel();
                }
            });
    
  • You can also set Alert Dialog type for all style, Such as
  • dialog.setDialogType(CustomAlertDialog.DialogType.ERROR);
    
    Currently available type are:
    CustomAlertDialog.DialogType.DEFAULT
    CustomAlertDialog.DialogType.ERROR
    CustomAlertDialog.DialogType.SUCCESS
    CustomAlertDialog.DialogType.INFO
    CustomAlertDialog.DialogType.WARNING
    
  • For NO_ACTION_BAR and FILL_STYLE alert style you can set your own image drawable along with image tint color if you don't want image tint you can simply set this attribute to 0
    dialog.setDialogImage(getDrawable(R.drawable.alert),0); // no tint
    dialog.setDialogImage(getDrawable(R.drawable.alert),getResources().getColor(R.color.colorWhite)); //with tint
    
  • You can also define size of image you set by using this method
  • dialog.setImageSize(150,150);
    
  • Finally you can create and show your alert Don't forget to add this two
    dialog.create();
    dialog.show();
    

    This is my first library, so hope you guys enjoy its and feel free to give any suggesting.

  • alertdialog's People

    Stargazers

     avatar  avatar  avatar  avatar  avatar  avatar

    Watchers

     avatar

    Forkers

    1541996

    Recommend Projects

    • React photo React

      A declarative, efficient, and flexible JavaScript library for building user interfaces.

    • Vue.js photo Vue.js

      ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

    • Typescript photo Typescript

      TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    • TensorFlow photo TensorFlow

      An Open Source Machine Learning Framework for Everyone

    • Django photo Django

      The Web framework for perfectionists with deadlines.

    • D3 photo D3

      Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

    Recommend Topics

    • javascript

      JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

    • web

      Some thing interesting about web. New door for the world.

    • server

      A server is a program made to process requests and deliver data to clients.

    • Machine learning

      Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

    • Game

      Some thing interesting about game, make everyone happy.

    Recommend Org

    • Facebook photo Facebook

      We are working to build community through open source technology. NB: members must have two-factor auth.

    • Microsoft photo Microsoft

      Open source projects and samples from Microsoft.

    • Google photo Google

      Google โค๏ธ Open Source for everyone.

    • D3 photo D3

      Data-Driven Documents codes.