SlideShare a Scribd company logo
ProgressDialog/AlertDialog/CustomAlertDialog
1
Sourabh Sahu
ProgressDialog progressDialog;
• ProgressDialog progressDialog;
• //In OnCreate Method
• progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setMessage("Loading..."); // Setting
• Message progressDialog.setTitle("ProgressDialog"); // Setting
Title
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNE
R); // Progress Dialog Style Spinner progressDialog.show(); //
• Display Progress Dialog progressDialog.setCancelable(false);
new Thread(new Runnable() {
• public void run() {
• try {
• Thread.sleep(10000);
• }
• catch (Exception e) {
• e.printStackTrace();
• }
• progressDialog.dismiss();
• }
• }).start();
Horizontal Progress Dialog
• progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setMax(100);
• // Progress Dialog Max Value
progressDialog.setMessage("Loading..."); // Setting Message
progressDialog.setTitle("ProgressDialog"); // Setting Title
• progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZON
TAL); // Progress Dialog Style Horizontal
• progressDialog.show(); // Display Progress Dialog
progressDialog.setCancelable(false);
• new Thread(new Runnable() {
• @Override public void run() {
• try {
• while (progressDialog.getProgress() <= progressDialog.getMax())
{
• Thread.sleep(200);
• handle.sendMessage(handle.obtainMessage());
• if (progressDialog.getProgress() == progressDialog.getMax()) {
• progressDialog.dismiss();
• }
• }
• } catch (Exception e) {
• e.printStackTrace();
• } } }).start();
Methods
1. setTitle(CharSequence title) – This component is used to set the
title of the progress dialog.
// Setting Title progressDialog.setTitle("ProgressDialog");
2. setMessage(CharSequence message) – This component displays
the required message in the progress dialog.
// Setting Message progressDialog.setMessage("Loading...");
3. setProgressStyle(ProgressDialog.STYLE_HORIZONTAL) – This is
used for setting the horizontal style of the progress dialog.
// Progress Dialog Style Horizontal
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
4. setProgressStyle(ProgressDialog.STYLE_SPINNER) – This is used
for setting the spinner style of the progress dialog.
// Progress Dialog Style Spinner
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
•
5. setMax(int max) – This method sets the maximum value of the progress dialog.
• // Progress Dialog Max Value progressDialog.setMax(100);
• 6. getMax() – This method return the maximum value of the progress dialog,
basically this method is used while applying condition over the progress dialog.
• // Fetching max value progressDialog.getMax();
• 7. getProgess() – This returns current progress of the progress dialog in numeric.
• // Fetching current progress progressDialog.getProgress();
• 8. incrementProgressBy(int diff) – This method increments the progress dialog
value with the defined value.
• // Incremented By Value 2 progressDialog.incrementProgressBy(2);
• 9. setCancelable(boolean cancelable) – This method has boolean value i.e
true/false. If set to false it allows to cancel the dialog box by clicking on area outside
the dialog default it is true if method is not used.
• // Cannot Cancel Progress Dialog progressDialog.setCancelable(false);
• 10. dismiss() – This method dismiss the progressdialog.
• //Dismiss the dialog progressDialog.dismiss();
AlertDialog
• AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
• // Setting Alert Dialog Title
• alertDialogBuilder.setTitle("Confirm..!!!");
• // Icon Of Alert Dialog alertDialogBuilder.setIcon(R.drawable.ask);
• // Setting Alert Dialog Message
• alertDialogBuilder.setMessage(“Do you want to continue");
alertDialogBuilder.setCancelable(false);
• alertDialogBuilder.setPositiveButton("Yes", new
DialogInterface.OnClickListener() {
• @Override public void onClick(DialogInterface arg0, int arg1) {
• finish(); } });
• alertDialogBuilder.setNegativeButton("No", new
DialogInterface.OnClickListener() { @Override public void
onClick(DialogInterface dialog, int which)
{ Toast.makeText(MainActivity.this,"You
Continued",Toast.LENGTH_SHORT).show(); } });
• alertDialogBuilder.setNeutralButton("Cancel",
new DialogInterface.OnClickListener() {
• @Override public void onClick(DialogInterface
dialog, int which)
{ Toast.makeText(getApplicationContext(),“You
have canceled the
choice",Toast.LENGTH_SHORT).show(); } });
• AlertDialog alertDialog =
alertDialogBuilder.create(); alertDialog.show();
• 1. setTitle(CharSequence title) – This component is used to
set the title of the alert dialog. It is optional component.
• // Setting Alert Dialog Title
alertDialogBuilder.setTitle(“Confirm..!!!");
• 2. setIcon(Drawable icon) – This component add icon before
the title. You will need to save image in drawable icon.
• // Icon Of Alert Dialog alertDialogBuilder.setIcon(R.drawable.ask);
• 3. setMessage(CharSequence message) – This component
displays the required message in the alert dialog.
• // Setting Alert Dialog Message
alertDialogBuilder.setMessage("Are you sure,Dou you want to
continue");
• 4. setCancelable(boolean cancelable) – This component has
boolean value i.e true/false. If set to false it allows to cancel the
dialog box by clicking on area outside the dialog else it allows.
• alertDialogBuilder.setCancelable(false);
• 5. setPositiveButton(CharSequence text, DialogInterface.OnClickListener
listener) – This component add positive button and further with this user confirm he
wants the alert dialog question to happen.
• alertDialogBuilder.setPositiveButton("yes", new DialogInterface.OnClickListener()
{ @Override public void onClick(DialogInterface arg0, int arg1) { finish(); } });
• 6. setNegativeButton(CharSequence text, DialogInterface.OnClickListener
listener) – This component add negative button and further with this user confirm
he doesn’t want the alert dialog question to happen.
• alertDialogBuilder.setNegativeButton("No", new DialogInterface.OnClickListener()
{ @Override public void onClick(DialogInterface dialog, int which)
{ Toast.makeText(MainActivity.this,"You clicked over
No",Toast.LENGTH_SHORT).show(); } });
• 7. setNeutralButton(CharSequence text, DialogInterface.OnClickListener
listener) – This component simply add a new button and on this button developer
can set any other onclick functionality like cancel button on alert dialog.
• alertDialogBuilder.setNeutralButton("Cancel", new DialogInterface.OnClickListener()
{ @Override public void onClick(DialogInterface dialog, int which)
{ Toast.makeText(getApplicationContext(),"You clicked on
Cancel",Toast.LENGTH_SHORT).show(); } });
Custom Alert
• To Make Custom Alert,You have design a
layout that will be inflatedto
AlertDialogBuilder
Customalert.xml
• <?xml version="1.0" encoding="utf-8"?>
• <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"> <
• TextView android:text="@string/alert"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/text"
android:textStyle="normal|bold" android:textSize="18sp"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/image"
android:layout_toEndOf="@+id/image" android:layout_marginLeft="21dp"
android:layout_marginStart="21dp" android:layout_marginTop="12dp" />
<
• ImageButton android:layout_width="35dp"
android:layout_height="35dp" app:srcCompat="@drawable/stop"
android:id="@+id/image" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
tools:ignore="ContentDescription,RtlHardcoded" /> <
• Button android:id="@+id/dialogButtonOK"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="@string/dismiss"
android:layout_marginTop="23dp" android:paddingRight="5dp"
android:layout_below="@+id/image"
android:layout_alignLeft="@+id/image"
android:layout_alignStart="@+id/image" android:textSize="18sp"
style="@style/Widget.AppCompat.Button.Colored“ />
</RelativeLayout>
Setting View
• final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.custom); Button
dialogButton = (Button)
dialog.findViewById(R.id.dialogButtonOK); // if
button is clicked, close the custom dialog
dialogButton.setOnClickListener(new
View.OnClickListener() { @Override public void
onClick(View v) { dialog.dismiss();
Toast.makeText(getApplicationContext(),"Dismiss
ed..!!",Toast.LENGTH_SHORT).show(); } });
dialog.show();
Thank You
16

More Related Content

What's hot

Labels and buttons
Labels and buttonsLabels and buttons
Labels and buttonsmyrajendra
 
Awt and swing in java
Awt and swing in javaAwt and swing in java
Awt and swing in java
Shehrevar Davierwala
 
The AWT and Swing
The AWT and SwingThe AWT and Swing
The AWT and Swing
adil raja
 
Advance Java Programming (CM5I) 1.AWT
Advance Java Programming (CM5I) 1.AWTAdvance Java Programming (CM5I) 1.AWT
Advance Java Programming (CM5I) 1.AWT
Payal Dungarwal
 
Graphical User Components Part 2
Graphical User Components Part 2Graphical User Components Part 2
Graphical User Components Part 2
Andy Juan Sarango Veliz
 
IP project for class 12 cbse
IP project for class 12 cbseIP project for class 12 cbse
IP project for class 12 cbse
siddharthjha34
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
shanmuga rajan
 
tL19 awt
tL19 awttL19 awt
tL19 awt
teach4uin
 
Basic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in JavaBasic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in Java
suraj pandey
 
Awt controls ppt
Awt controls pptAwt controls ppt
Awt controls ppt
soumyaharitha
 
Dr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWTDr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWT
DrRajeshreeKhande
 
Cordova training : Day 6 - UI development using Framework7
Cordova training : Day 6 - UI development using Framework7Cordova training : Day 6 - UI development using Framework7
Cordova training : Day 6 - UI development using Framework7
Binu Paul
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
PRN USM
 
Advance Java Programming (CM5I) 2.Swing
Advance Java Programming (CM5I) 2.SwingAdvance Java Programming (CM5I) 2.Swing
Advance Java Programming (CM5I) 2.Swing
Payal Dungarwal
 
GUI components in Java
GUI components in JavaGUI components in Java
GUI components in Java
kirupasuchi1996
 

What's hot (20)

Ingles 2do parcial
Ingles   2do parcialIngles   2do parcial
Ingles 2do parcial
 
Labels and buttons
Labels and buttonsLabels and buttons
Labels and buttons
 
Awt and swing in java
Awt and swing in javaAwt and swing in java
Awt and swing in java
 
The AWT and Swing
The AWT and SwingThe AWT and Swing
The AWT and Swing
 
Advance Java Programming (CM5I) 1.AWT
Advance Java Programming (CM5I) 1.AWTAdvance Java Programming (CM5I) 1.AWT
Advance Java Programming (CM5I) 1.AWT
 
swingbasics
swingbasicsswingbasics
swingbasics
 
Graphical User Components Part 2
Graphical User Components Part 2Graphical User Components Part 2
Graphical User Components Part 2
 
IP project for class 12 cbse
IP project for class 12 cbseIP project for class 12 cbse
IP project for class 12 cbse
 
java2 swing
java2 swingjava2 swing
java2 swing
 
Oop lecture9 10
Oop lecture9 10Oop lecture9 10
Oop lecture9 10
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
 
tL19 awt
tL19 awttL19 awt
tL19 awt
 
28 awt
28 awt28 awt
28 awt
 
Basic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in JavaBasic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in Java
 
Awt controls ppt
Awt controls pptAwt controls ppt
Awt controls ppt
 
Dr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWTDr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWT
 
Cordova training : Day 6 - UI development using Framework7
Cordova training : Day 6 - UI development using Framework7Cordova training : Day 6 - UI development using Framework7
Cordova training : Day 6 - UI development using Framework7
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
 
Advance Java Programming (CM5I) 2.Swing
Advance Java Programming (CM5I) 2.SwingAdvance Java Programming (CM5I) 2.Swing
Advance Java Programming (CM5I) 2.Swing
 
GUI components in Java
GUI components in JavaGUI components in Java
GUI components in Java
 

Similar to Progress Dialog, AlertDialog, CustomDialog

Android Lab Test : Creating a dialog Yes/No (english)
Android Lab Test : Creating a dialog Yes/No (english)Android Lab Test : Creating a dialog Yes/No (english)
Android Lab Test : Creating a dialog Yes/No (english)
Bruno Delb
 
Android basics – dialogs and floating activities
Android basics – dialogs and floating activitiesAndroid basics – dialogs and floating activities
Android basics – dialogs and floating activities
info_zybotech
 
Introduction to Griffon
Introduction to GriffonIntroduction to Griffon
Introduction to Griffon
James Williams
 
Menu bars and menus
Menu bars and menusMenu bars and menus
Menu bars and menusmyrajendra
 
Maze
MazeMaze
Maze
yito24
 
Bot builder v4 HOL
Bot builder v4 HOLBot builder v4 HOL
Bot builder v4 HOL
Cheah Eng Soon
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
ciklum_ods
 
JavaScript Refactoring
JavaScript RefactoringJavaScript Refactoring
JavaScript Refactoring
Krzysztof Szafranek
 
Google guava
Google guavaGoogle guava
Java awt
Java awtJava awt
Checkbox and checkbox group
Checkbox and checkbox groupCheckbox and checkbox group
Checkbox and checkbox groupmyrajendra
 
Settings
SettingsSettings
Settings
yito24
 
Httpsitesgooglecomsitekaratasajtov
HttpsitesgooglecomsitekaratasajtovHttpsitesgooglecomsitekaratasajtov
HttpsitesgooglecomsitekaratasajtovЮля Шуба
 
Developing Google Glass
Developing Google GlassDeveloping Google Glass
Developing Google Glass
Johnny Sung
 
Angular JS2 Training Session #2
Angular JS2 Training Session #2Angular JS2 Training Session #2
Angular JS2 Training Session #2
Paras Mendiratta
 
Quick Intro to Android Development
Quick Intro to Android DevelopmentQuick Intro to Android Development
Quick Intro to Android DevelopmentJussi Pohjolainen
 
JavaScript, React Native and Performance at react-europe 2016
JavaScript, React Native and Performance at react-europe 2016JavaScript, React Native and Performance at react-europe 2016
JavaScript, React Native and Performance at react-europe 2016
Tadeu Zagallo
 
Lists and scrollbars
Lists and scrollbarsLists and scrollbars
Lists and scrollbarsmyrajendra
 
GWT Training - Session 2/3
GWT Training - Session 2/3GWT Training - Session 2/3
GWT Training - Session 2/3
Faiz Bashir
 

Similar to Progress Dialog, AlertDialog, CustomDialog (20)

Android Lab Test : Creating a dialog Yes/No (english)
Android Lab Test : Creating a dialog Yes/No (english)Android Lab Test : Creating a dialog Yes/No (english)
Android Lab Test : Creating a dialog Yes/No (english)
 
Advance JFACE
Advance JFACEAdvance JFACE
Advance JFACE
 
Android basics – dialogs and floating activities
Android basics – dialogs and floating activitiesAndroid basics – dialogs and floating activities
Android basics – dialogs and floating activities
 
Introduction to Griffon
Introduction to GriffonIntroduction to Griffon
Introduction to Griffon
 
Menu bars and menus
Menu bars and menusMenu bars and menus
Menu bars and menus
 
Maze
MazeMaze
Maze
 
Bot builder v4 HOL
Bot builder v4 HOLBot builder v4 HOL
Bot builder v4 HOL
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
JavaScript Refactoring
JavaScript RefactoringJavaScript Refactoring
JavaScript Refactoring
 
Google guava
Google guavaGoogle guava
Google guava
 
Java awt
Java awtJava awt
Java awt
 
Checkbox and checkbox group
Checkbox and checkbox groupCheckbox and checkbox group
Checkbox and checkbox group
 
Settings
SettingsSettings
Settings
 
Httpsitesgooglecomsitekaratasajtov
HttpsitesgooglecomsitekaratasajtovHttpsitesgooglecomsitekaratasajtov
Httpsitesgooglecomsitekaratasajtov
 
Developing Google Glass
Developing Google GlassDeveloping Google Glass
Developing Google Glass
 
Angular JS2 Training Session #2
Angular JS2 Training Session #2Angular JS2 Training Session #2
Angular JS2 Training Session #2
 
Quick Intro to Android Development
Quick Intro to Android DevelopmentQuick Intro to Android Development
Quick Intro to Android Development
 
JavaScript, React Native and Performance at react-europe 2016
JavaScript, React Native and Performance at react-europe 2016JavaScript, React Native and Performance at react-europe 2016
JavaScript, React Native and Performance at react-europe 2016
 
Lists and scrollbars
Lists and scrollbarsLists and scrollbars
Lists and scrollbars
 
GWT Training - Session 2/3
GWT Training - Session 2/3GWT Training - Session 2/3
GWT Training - Session 2/3
 

More from Sourabh Sahu

Understanding GIT and Version Control
Understanding GIT and Version ControlUnderstanding GIT and Version Control
Understanding GIT and Version Control
Sourabh Sahu
 
Python Seaborn Data Visualization
Python Seaborn Data Visualization Python Seaborn Data Visualization
Python Seaborn Data Visualization
Sourabh Sahu
 
Mongo db Quick Guide
Mongo db Quick GuideMongo db Quick Guide
Mongo db Quick Guide
Sourabh Sahu
 
Python Course
Python CoursePython Course
Python Course
Sourabh Sahu
 
Android styles and themes
Android styles and themesAndroid styles and themes
Android styles and themes
Sourabh Sahu
 
SeekBar in Android
SeekBar in AndroidSeekBar in Android
SeekBar in Android
Sourabh Sahu
 
Android layouts
Android layoutsAndroid layouts
Android layouts
Sourabh Sahu
 
Android ListView and Custom ListView
Android ListView and Custom ListView Android ListView and Custom ListView
Android ListView and Custom ListView
Sourabh Sahu
 
Activities
ActivitiesActivities
Activities
Sourabh Sahu
 
Android project architecture
Android project architectureAndroid project architecture
Android project architecture
Sourabh Sahu
 
Shared preferences
Shared preferencesShared preferences
Shared preferences
Sourabh Sahu
 
Content Providers in Android
Content Providers in AndroidContent Providers in Android
Content Providers in Android
Sourabh Sahu
 
SQLITE Android
SQLITE AndroidSQLITE Android
SQLITE Android
Sourabh Sahu
 
Calendar, Clocks, DatePicker and TimePicker
Calendar, Clocks, DatePicker and TimePickerCalendar, Clocks, DatePicker and TimePicker
Calendar, Clocks, DatePicker and TimePicker
Sourabh Sahu
 
AutocompleteTextView And MultiAutoCompleteTextView
AutocompleteTextView And MultiAutoCompleteTextViewAutocompleteTextView And MultiAutoCompleteTextView
AutocompleteTextView And MultiAutoCompleteTextView
Sourabh Sahu
 
Web view
Web viewWeb view
Web view
Sourabh Sahu
 
Parceable serializable
Parceable serializableParceable serializable
Parceable serializable
Sourabh Sahu
 
Android Architecture
Android ArchitectureAndroid Architecture
Android Architecture
Sourabh Sahu
 
Android Installation Testing
Android Installation TestingAndroid Installation Testing
Android Installation Testing
Sourabh Sahu
 
Android Installation
Android Installation Android Installation
Android Installation
Sourabh Sahu
 

More from Sourabh Sahu (20)

Understanding GIT and Version Control
Understanding GIT and Version ControlUnderstanding GIT and Version Control
Understanding GIT and Version Control
 
Python Seaborn Data Visualization
Python Seaborn Data Visualization Python Seaborn Data Visualization
Python Seaborn Data Visualization
 
Mongo db Quick Guide
Mongo db Quick GuideMongo db Quick Guide
Mongo db Quick Guide
 
Python Course
Python CoursePython Course
Python Course
 
Android styles and themes
Android styles and themesAndroid styles and themes
Android styles and themes
 
SeekBar in Android
SeekBar in AndroidSeekBar in Android
SeekBar in Android
 
Android layouts
Android layoutsAndroid layouts
Android layouts
 
Android ListView and Custom ListView
Android ListView and Custom ListView Android ListView and Custom ListView
Android ListView and Custom ListView
 
Activities
ActivitiesActivities
Activities
 
Android project architecture
Android project architectureAndroid project architecture
Android project architecture
 
Shared preferences
Shared preferencesShared preferences
Shared preferences
 
Content Providers in Android
Content Providers in AndroidContent Providers in Android
Content Providers in Android
 
SQLITE Android
SQLITE AndroidSQLITE Android
SQLITE Android
 
Calendar, Clocks, DatePicker and TimePicker
Calendar, Clocks, DatePicker and TimePickerCalendar, Clocks, DatePicker and TimePicker
Calendar, Clocks, DatePicker and TimePicker
 
AutocompleteTextView And MultiAutoCompleteTextView
AutocompleteTextView And MultiAutoCompleteTextViewAutocompleteTextView And MultiAutoCompleteTextView
AutocompleteTextView And MultiAutoCompleteTextView
 
Web view
Web viewWeb view
Web view
 
Parceable serializable
Parceable serializableParceable serializable
Parceable serializable
 
Android Architecture
Android ArchitectureAndroid Architecture
Android Architecture
 
Android Installation Testing
Android Installation TestingAndroid Installation Testing
Android Installation Testing
 
Android Installation
Android Installation Android Installation
Android Installation
 

Recently uploaded

Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 

Recently uploaded (20)

Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 

Progress Dialog, AlertDialog, CustomDialog

  • 2. ProgressDialog progressDialog; • ProgressDialog progressDialog; • //In OnCreate Method • progressDialog = new ProgressDialog(MainActivity.this); progressDialog.setMessage("Loading..."); // Setting • Message progressDialog.setTitle("ProgressDialog"); // Setting Title progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNE R); // Progress Dialog Style Spinner progressDialog.show(); // • Display Progress Dialog progressDialog.setCancelable(false); new Thread(new Runnable() { • public void run() { • try {
  • 3. • Thread.sleep(10000); • } • catch (Exception e) { • e.printStackTrace(); • } • progressDialog.dismiss(); • } • }).start();
  • 4. Horizontal Progress Dialog • progressDialog = new ProgressDialog(MainActivity.this); progressDialog.setMax(100); • // Progress Dialog Max Value progressDialog.setMessage("Loading..."); // Setting Message progressDialog.setTitle("ProgressDialog"); // Setting Title • progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZON TAL); // Progress Dialog Style Horizontal • progressDialog.show(); // Display Progress Dialog progressDialog.setCancelable(false); • new Thread(new Runnable() { • @Override public void run() { • try { • while (progressDialog.getProgress() <= progressDialog.getMax()) {
  • 5. • Thread.sleep(200); • handle.sendMessage(handle.obtainMessage()); • if (progressDialog.getProgress() == progressDialog.getMax()) { • progressDialog.dismiss(); • } • } • } catch (Exception e) { • e.printStackTrace(); • } } }).start();
  • 6. Methods 1. setTitle(CharSequence title) – This component is used to set the title of the progress dialog. // Setting Title progressDialog.setTitle("ProgressDialog"); 2. setMessage(CharSequence message) – This component displays the required message in the progress dialog. // Setting Message progressDialog.setMessage("Loading..."); 3. setProgressStyle(ProgressDialog.STYLE_HORIZONTAL) – This is used for setting the horizontal style of the progress dialog. // Progress Dialog Style Horizontal progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); 4. setProgressStyle(ProgressDialog.STYLE_SPINNER) – This is used for setting the spinner style of the progress dialog. // Progress Dialog Style Spinner progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
  • 7. • 5. setMax(int max) – This method sets the maximum value of the progress dialog. • // Progress Dialog Max Value progressDialog.setMax(100); • 6. getMax() – This method return the maximum value of the progress dialog, basically this method is used while applying condition over the progress dialog. • // Fetching max value progressDialog.getMax(); • 7. getProgess() – This returns current progress of the progress dialog in numeric. • // Fetching current progress progressDialog.getProgress(); • 8. incrementProgressBy(int diff) – This method increments the progress dialog value with the defined value. • // Incremented By Value 2 progressDialog.incrementProgressBy(2); • 9. setCancelable(boolean cancelable) – This method has boolean value i.e true/false. If set to false it allows to cancel the dialog box by clicking on area outside the dialog default it is true if method is not used. • // Cannot Cancel Progress Dialog progressDialog.setCancelable(false); • 10. dismiss() – This method dismiss the progressdialog. • //Dismiss the dialog progressDialog.dismiss();
  • 8. AlertDialog • AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); • // Setting Alert Dialog Title • alertDialogBuilder.setTitle("Confirm..!!!"); • // Icon Of Alert Dialog alertDialogBuilder.setIcon(R.drawable.ask); • // Setting Alert Dialog Message • alertDialogBuilder.setMessage(“Do you want to continue"); alertDialogBuilder.setCancelable(false); • alertDialogBuilder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { • @Override public void onClick(DialogInterface arg0, int arg1) { • finish(); } }); • alertDialogBuilder.setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(MainActivity.this,"You Continued",Toast.LENGTH_SHORT).show(); } });
  • 9. • alertDialogBuilder.setNeutralButton("Cancel", new DialogInterface.OnClickListener() { • @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(getApplicationContext(),“You have canceled the choice",Toast.LENGTH_SHORT).show(); } }); • AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show();
  • 10. • 1. setTitle(CharSequence title) – This component is used to set the title of the alert dialog. It is optional component. • // Setting Alert Dialog Title alertDialogBuilder.setTitle(“Confirm..!!!"); • 2. setIcon(Drawable icon) – This component add icon before the title. You will need to save image in drawable icon. • // Icon Of Alert Dialog alertDialogBuilder.setIcon(R.drawable.ask); • 3. setMessage(CharSequence message) – This component displays the required message in the alert dialog. • // Setting Alert Dialog Message alertDialogBuilder.setMessage("Are you sure,Dou you want to continue"); • 4. setCancelable(boolean cancelable) – This component has boolean value i.e true/false. If set to false it allows to cancel the dialog box by clicking on area outside the dialog else it allows. • alertDialogBuilder.setCancelable(false);
  • 11. • 5. setPositiveButton(CharSequence text, DialogInterface.OnClickListener listener) – This component add positive button and further with this user confirm he wants the alert dialog question to happen. • alertDialogBuilder.setPositiveButton("yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { finish(); } }); • 6. setNegativeButton(CharSequence text, DialogInterface.OnClickListener listener) – This component add negative button and further with this user confirm he doesn’t want the alert dialog question to happen. • alertDialogBuilder.setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(MainActivity.this,"You clicked over No",Toast.LENGTH_SHORT).show(); } }); • 7. setNeutralButton(CharSequence text, DialogInterface.OnClickListener listener) – This component simply add a new button and on this button developer can set any other onclick functionality like cancel button on alert dialog. • alertDialogBuilder.setNeutralButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(getApplicationContext(),"You clicked on Cancel",Toast.LENGTH_SHORT).show(); } });
  • 12. Custom Alert • To Make Custom Alert,You have design a layout that will be inflatedto AlertDialogBuilder
  • 13. Customalert.xml • <?xml version="1.0" encoding="utf-8"?> • <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> < • TextView android:text="@string/alert" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/text" android:textStyle="normal|bold" android:textSize="18sp" android:layout_alignParentTop="true" android:layout_toRightOf="@+id/image" android:layout_toEndOf="@+id/image" android:layout_marginLeft="21dp" android:layout_marginStart="21dp" android:layout_marginTop="12dp" /> <
  • 14. • ImageButton android:layout_width="35dp" android:layout_height="35dp" app:srcCompat="@drawable/stop" android:id="@+id/image" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_marginLeft="5dp" android:layout_marginTop="5dp" tools:ignore="ContentDescription,RtlHardcoded" /> < • Button android:id="@+id/dialogButtonOK" android:layout_width="200dp" android:layout_height="wrap_content" android:text="@string/dismiss" android:layout_marginTop="23dp" android:paddingRight="5dp" android:layout_below="@+id/image" android:layout_alignLeft="@+id/image" android:layout_alignStart="@+id/image" android:textSize="18sp" style="@style/Widget.AppCompat.Button.Colored“ /> </RelativeLayout>
  • 15. Setting View • final Dialog dialog = new Dialog(context); dialog.setContentView(R.layout.custom); Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK); // if button is clicked, close the custom dialog dialogButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); Toast.makeText(getApplicationContext(),"Dismiss ed..!!",Toast.LENGTH_SHORT).show(); } }); dialog.show();