Alert, Dialog & Toast


 

  1. AlertDialog
  2. AlertDialog with ListItems
  3. AlertDialog with Custom ListItems
  4. AlertDialog with Single Choice
  5. AlertDialog with Multiple Choice
  6. AlertDialog with View
  7. ProgressDialog
  8. Custom Dialog
  9. Dialog Fragment
  10. Dialog Fragment with AlertDialog
  11. Toast
  12. Custom Toast

 

1. AlertDialog
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.
Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open AndroidManifest.xml and add following code :

ScreenShot:

dialog dialog2 dialog3

Download_button

 

2. AlertDialog with ListItems
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.
Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open AndroidManifest.xml and add following code :

ScreenShot:

dialog_list dialog_list2 dialog_list3

Download_button

 

3. AlertDialog with Custom ListView
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.
Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open res -> layout -> Create new xml, listitem_row.xml and add following code :

Step 4 : Open src -> package -> MainActivity.java and add following code :

Step 5 : Open src -> package -> Create new class, CustomListAdapter.java and add following code :

Step 6 : Open AndroidManifest.xml and add following code :

ScreenShot:

alert_custom_adapter2 alert_custom_adapter

Download SourceCode

 

4. AlertDialog with Single Choice
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.
Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open AndroidManifest.xml and add following code :

ScreenShot:

dialog_single dialog_single2 dialog_single3

Download_button

 

5. AlertDialog with Multiple Choice
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.
Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open AndroidManifest.xml and add following code :

ScreenShot:

dialog_multi dialog_multi2 dialog_multi3

Download_button

 

6. AlertDialog with View
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.
Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open res -> layout -> Create new xml file, alert_dialog_text_entry.xml and add following code :

Step 4 : Open src -> package -> MainActivity.java and add following code :

Step 5 : Open AndroidManifest.xml and add following code :

ScreenShot:

dialog_view dialog_view22 dialog_view3

Download_button

 

7. ProgressDialog
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open AndroidManifest.xml and add following code :

ScreenShot:

progress_dialog progress_dialog2

Download_button

 

8. Custom Dialog with WebView
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.
Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open res -> layout ->Create new XML file, dialog_webview.xml and add following code :

Step 4 : Open src -> package -> MainActivity.java and add following code :

Step 5 : Open AndroidManifest.xml and add following code :

ScreenShot:

dialog_web dialog_web2

Download_button

 

9. Dialog Fragment
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.
Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open res -> layout -> Create new xml file, dialog_fragment.xml and add following code :

Step 5 : Open src -> package ->Create new Class, MyDialogFragment.java and add following code :

Step 6 : Open AndroidManifest.xml and add following code :

ScreenShot:

dialog_fragdialog_frag2

Download SourceCode

 

10. Dialog Fragment with AlertDialog
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.
Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open src -> package -> MainActivity.java and add following code :

Step 5 : Open AndroidManifest.xml and add following code :

ScreenShot:

dialog_frag_alert dialog_frag_alert2

Download SourceCode

 

11. Toast
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.
Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open AndroidManifest.xml and add following code :

ScreenShot:

toast toast2

Download_button

 

12. Custom Toast
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.
Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open AndroidManifest.xml and add following code :

ScreenShot:

custom_toast custom_toast2

Download_button