How to create android alertdialog custom layout message ? - SpartaCode

SpartaCode

Make your development faster and easier !

How to create android alertdialog custom layout message ?



To make your app beautiful and standard we need to provide messages in extra ordinary way instead of using any kind of toast messages which are quite usual.


So im here with simple util file which will create dialogs in just 2 lines.


Note: Copy this file into your Android project.


Copy this into your colors.xml file in values :



<color name="warning">#ffbaba</color>
<color name="error">#d8000c</color>
<color name="success">#dff2bf</color>


Step 1: Download supporting layout file



Note: Copy this file into your layout package in res folder.



Step 2: Use Message dialog in your Activity




MessageDialog messagedialog=new MessageDialog(MainActivity.this);
messagedialog.showMessageDialog("Hello this is beautiful message dialog","Success");

Add this to your style.xml :

 <style name="PauseDialogAnimation">
        <item name="android:windowEnterAnimation">@anim/push_right_in</item>
        <item name="android:windowExitAnimation">@android:anim/slide_out_right</item>
    </style>

Where,

Syntax :
showMessageDialog(<Message> , <Type>);

<Type>  : "Success" OR "Warning"


Note : You may have some errors in MessageDialog.java file which will be missing resource files.
You can replace it with your image drawables.


Thank You
Like and Subscribe



2 comments:

  1. Nice tutorial... Thanks!!! I have implemented this in my app and it has made my app look more pleasant

    ReplyDelete

News

Get Amazing Traffic to your Site

Traffic Exchange

Post Bottom Ad

Responsive Ads Here