SlideShare a Scribd company logo
Android Dialogs
Perfect APK
Android Dialogs Tutorial
Popups or dialogs are a common to prompt the user to take action. Android popups are called Dialogs. The base dialog class is extended by
AlertDialog class, which is extended by more specific dialog classes:
● DatePickerDialog
● ProgressDialog
● TimePickerDialog
In this tutorial we will create AlertDialogs using the AlertDialog.Builder helper class.
AlertDialogs are divided into the following components:
● Title Area
● Content Area
● Buttons - Positive, negative and neutral
None of the components are mandatory, and for each components there is a default view. In this tutorial we will see 3 examples:
● Single-Choice Dialog
● Dialog with buttons
Single-Choice Dialog
This example uses the following default components:
● Title Area - The default title view which is actually a TextView. The view is set using the setTitle() method of the AlertDialog.Builder class.
● Content Area - The default single-choice ListView which is actually a RadioGroup. The view is set using the setSingleChoiceItems() method of
the AlertDialog.Builder class.
The AlertDialog in this example is created using the following code:
1. builder = new AlertDialog.Builder(mContext);
2. builder.setTitle(R.string.dialog_single_choice_title);
3. builder.setSingleChoiceItems(R.array.color_names, mSingleChoicePosition, this);
4. mAlertDialog = builder.create();
5. mAlertDialog.show();
The color_names array is described in the res/values/color_names.xml file below:
1. <?xml version="1.0" encoding="utf-8"?>
2. <resources>
Dialog With Buttons
This example uses the following default components:
● Title Area - The default title view which is actually a TextView. The view is set using the setTitle() method of the
AlertDialog.Builder class.
● Content Area - The default message view which is actually a TextView. The view is set using the setMessage() method of the
AlertDialog.Builder class.
● Buttons - Positive and Negative buttons are set using the setPositiveButton() and setNegativeButton() methods of the
AlertDialog.Builder class.
The AlertDialog in this example is created using the following code:
1. builder = new AlertDialog.Builder(mContext);
2. builder.setTitle(R.string.dialog_with_buttons_title);
3. builder.setMessage(R.string.dialog_with_buttons_message);
4. builder.setPositiveButton(R.string.dialog_with_buttons_positive, this);
Custom Dialog
This example uses only the content component, for the following res/layout/custom_dialog.xml file is used:
1. <?xml version="1.0" encoding="utf-8"?>
2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3. android:layout_width="match_parent"
4. android:layout_height="match_parent" >
5.
6. <TextView android:id="@+id/tvTitle"
7. android:layout_width="match_parent"
8. android:layout_height="wrap_content"
9. android:padding="5dp"
10. android:text="@string/dialog_custom_title"
11. android:textAppearance="@android:style/TextAppearance.Medium.Inverse"
Custom Dialog
1. <TextView android:id="@+id/tvContent"
2. android:layout_width="match_parent"
3. android:layout_height="wrap_content"
4. android:layout_below="@id/tvTitle"
5. android:text="@string/dialog_custom_text"
6. android:textAppearance="@android:style/TextAppearance.Large"
7. android:gravity="center"
8. android:textStyle="bold|italic"
9. android:paddingTop="20dp"
10. android:paddingBottom="20dp" />
11.
12. <RatingBar android:id="@+id/ratingBar"
Custom Dialog
The AlertDialog in this example is created using the following code:
1. LayoutInflater inflater = LayoutInflater.from(mContext);
2. builder = new AlertDialog.Builder(mContext);
3. builder.setTitle(null);
4. View customDialogView = inflater.inflate(R.layout.custom_dialog, null, false);
5. RatingBar ratingBar = (RatingBar) customDialogView.findViewById(R.id.ratingBar);
6. ratingBar.setRating(mRating);
7. ratingBar.setOnRatingBarChangeListener(this);
8. builder.setView(customDialogView);
9. mAlertDialog = builder.create();
10. mAlertDialog.show();

More Related Content

What's hot

Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
Ankit Dubey
 
Swings in java
Swings in javaSwings in java
Swings in java
Jyoti Totla
 
Java swing
Java swingJava swing
Java swing
ssuser3a47cb
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
JONDHLEPOLY
 
XMetaL Dialog Odds & Ends
XMetaL Dialog Odds & EndsXMetaL Dialog Odds & Ends
XMetaL Dialog Odds & Ends
XMetaL
 
Complete java swing
Complete java swingComplete java swing
Complete java swing
jehan1987
 
Awt and swing in java
Awt and swing in javaAwt and swing in java
Awt and swing in java
Shehrevar Davierwala
 
Microsoft visual basic 6
Microsoft visual basic 6Microsoft visual basic 6
Microsoft visual basic 6
Penang, Malaysia
 
User define data type In Visual Basic
User define data type In Visual Basic User define data type In Visual Basic
User define data type In Visual Basic
Shubham Dwivedi
 
tL19 awt
tL19 awttL19 awt
tL19 awt
teach4uin
 
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Java
yht4ever
 
Android notification
Android notificationAndroid notification
Android notification
Krazy Koder
 
Java- GUI- Mazenet solution
Java- GUI- Mazenet solutionJava- GUI- Mazenet solution
Java- GUI- Mazenet solution
Mazenetsolution
 
Basic using of Swing in Java
Basic using of Swing in JavaBasic using of Swing in Java
Basic using of Swing in Java
suraj pandey
 
JAVA GUI PART I
JAVA GUI PART IJAVA GUI PART I
JAVA GUI PART I
OXUS 20
 
[Android] Intent and Activity
[Android] Intent and Activity[Android] Intent and Activity
[Android] Intent and Activity
Nikmesoft Ltd
 
Spf chapter10 events
Spf chapter10 eventsSpf chapter10 events
Spf chapter10 events
Hock Leng PUAH
 
Androd Listeners
Androd ListenersAndrod Listeners
Androd Listeners
ksheerod shri toshniwal
 
Notification android
Notification androidNotification android
Notification android
ksheerod shri toshniwal
 
Gui in matlab :
Gui in matlab :Gui in matlab :
Gui in matlab :
elboob2025
 

What's hot (20)

Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
 
Swings in java
Swings in javaSwings in java
Swings in java
 
Java swing
Java swingJava swing
Java swing
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
 
XMetaL Dialog Odds & Ends
XMetaL Dialog Odds & EndsXMetaL Dialog Odds & Ends
XMetaL Dialog Odds & Ends
 
Complete java swing
Complete java swingComplete java swing
Complete java swing
 
Awt and swing in java
Awt and swing in javaAwt and swing in java
Awt and swing in java
 
Microsoft visual basic 6
Microsoft visual basic 6Microsoft visual basic 6
Microsoft visual basic 6
 
User define data type In Visual Basic
User define data type In Visual Basic User define data type In Visual Basic
User define data type In Visual Basic
 
tL19 awt
tL19 awttL19 awt
tL19 awt
 
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Java
 
Android notification
Android notificationAndroid notification
Android notification
 
Java- GUI- Mazenet solution
Java- GUI- Mazenet solutionJava- GUI- Mazenet solution
Java- GUI- Mazenet solution
 
Basic using of Swing in Java
Basic using of Swing in JavaBasic using of Swing in Java
Basic using of Swing in Java
 
JAVA GUI PART I
JAVA GUI PART IJAVA GUI PART I
JAVA GUI PART I
 
[Android] Intent and Activity
[Android] Intent and Activity[Android] Intent and Activity
[Android] Intent and Activity
 
Spf chapter10 events
Spf chapter10 eventsSpf chapter10 events
Spf chapter10 events
 
Androd Listeners
Androd ListenersAndrod Listeners
Androd Listeners
 
Notification android
Notification androidNotification android
Notification android
 
Gui in matlab :
Gui in matlab :Gui in matlab :
Gui in matlab :
 

Viewers also liked

Android basic 3 Dialogs
Android basic 3 DialogsAndroid basic 3 Dialogs
Android basic 3 Dialogs
Eakapong Kattiya
 
Alertdialog in android
Alertdialog in androidAlertdialog in android
Alertdialog in android
Durai S
 
Day1 what is android(print)
Day1 what is android(print)Day1 what is android(print)
Day1 what is android(print)
Dongchul Shin
 
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
 
2310 b xd
2310 b xd2310 b xd
2310 b xd
Krazy Koder
 
Goodbye progress dialog mess on Android
Goodbye progress dialog mess on AndroidGoodbye progress dialog mess on Android
Goodbye progress dialog mess on Android
Tsuyoshi Yoshioka
 

Viewers also liked (6)

Android basic 3 Dialogs
Android basic 3 DialogsAndroid basic 3 Dialogs
Android basic 3 Dialogs
 
Alertdialog in android
Alertdialog in androidAlertdialog in android
Alertdialog in android
 
Day1 what is android(print)
Day1 what is android(print)Day1 what is android(print)
Day1 what is android(print)
 
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)
 
2310 b xd
2310 b xd2310 b xd
2310 b xd
 
Goodbye progress dialog mess on Android
Goodbye progress dialog mess on AndroidGoodbye progress dialog mess on Android
Goodbye progress dialog mess on Android
 

Similar to Android Dialogs Tutorial

Android App Development 03 : Widget &amp; UI
Android App Development 03 : Widget &amp; UIAndroid App Development 03 : Widget &amp; UI
Android App Development 03 : Widget &amp; UI
Anuchit Chalothorn
 
Intake 38 9
Intake 38 9Intake 38 9
Intake 38 9
Mahmoud Ouf
 
Android session 3
Android session 3Android session 3
Android session 3
Ahesanali Suthar
 
Advance JFACE
Advance JFACEAdvance JFACE
Advance JFACE
Rahul Shukla
 
Android UI
Android UIAndroid UI
Android UI
nationalmobileapps
 
Intake 37 9
Intake 37 9Intake 37 9
Intake 37 9
Mahmoud Ouf
 
Gui builder
Gui builderGui builder
Gui builder
learnt
 
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
 
Django tutorial
Django tutorialDjango tutorial
Django tutorial
Ksd Che
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to android
Shrijan Tiwari
 
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAndroid User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Ahsanul Karim
 
android dilaogs
android dilaogsandroid dilaogs
android dilaogs
Deepa Rani
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI Widgets
Ahsanul Karim
 
Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]
Ahsanul Karim
 
PDF ON JAVA - JFC CONCEPT
PDF ON JAVA - JFC CONCEPTPDF ON JAVA - JFC CONCEPT
PDF ON JAVA - JFC CONCEPT
NAVYA RAO
 
08ui.pptx
08ui.pptx08ui.pptx
08ui.pptx
KabadaSori
 
Les14
Les14Les14
Oracle 10g Forms Lesson 15
Oracle 10g Forms Lesson  15Oracle 10g Forms Lesson  15
Oracle 10g Forms Lesson 15
KAMA3
 
Android User Interface: Basic Form Widgets
Android User Interface: Basic Form WidgetsAndroid User Interface: Basic Form Widgets
Android User Interface: Basic Form Widgets
Ahsanul Karim
 
The Ring programming language version 1.9 book - Part 82 of 210
The Ring programming language version 1.9 book - Part 82 of 210The Ring programming language version 1.9 book - Part 82 of 210
The Ring programming language version 1.9 book - Part 82 of 210
Mahmoud Samir Fayed
 

Similar to Android Dialogs Tutorial (20)

Android App Development 03 : Widget &amp; UI
Android App Development 03 : Widget &amp; UIAndroid App Development 03 : Widget &amp; UI
Android App Development 03 : Widget &amp; UI
 
Intake 38 9
Intake 38 9Intake 38 9
Intake 38 9
 
Android session 3
Android session 3Android session 3
Android session 3
 
Advance JFACE
Advance JFACEAdvance JFACE
Advance JFACE
 
Android UI
Android UIAndroid UI
Android UI
 
Intake 37 9
Intake 37 9Intake 37 9
Intake 37 9
 
Gui builder
Gui builderGui builder
Gui builder
 
Android basics – dialogs and floating activities
Android basics – dialogs and floating activitiesAndroid basics – dialogs and floating activities
Android basics – dialogs and floating activities
 
Django tutorial
Django tutorialDjango tutorial
Django tutorial
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to android
 
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAndroid User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
 
android dilaogs
android dilaogsandroid dilaogs
android dilaogs
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI Widgets
 
Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]
 
PDF ON JAVA - JFC CONCEPT
PDF ON JAVA - JFC CONCEPTPDF ON JAVA - JFC CONCEPT
PDF ON JAVA - JFC CONCEPT
 
08ui.pptx
08ui.pptx08ui.pptx
08ui.pptx
 
Les14
Les14Les14
Les14
 
Oracle 10g Forms Lesson 15
Oracle 10g Forms Lesson  15Oracle 10g Forms Lesson  15
Oracle 10g Forms Lesson 15
 
Android User Interface: Basic Form Widgets
Android User Interface: Basic Form WidgetsAndroid User Interface: Basic Form Widgets
Android User Interface: Basic Form Widgets
 
The Ring programming language version 1.9 book - Part 82 of 210
The Ring programming language version 1.9 book - Part 82 of 210The Ring programming language version 1.9 book - Part 82 of 210
The Ring programming language version 1.9 book - Part 82 of 210
 

Recently uploaded

Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
Grant Fritchey
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
Quickdice ERP
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 

Recently uploaded (20)

Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 

Android Dialogs Tutorial

  • 2. Android Dialogs Tutorial Popups or dialogs are a common to prompt the user to take action. Android popups are called Dialogs. The base dialog class is extended by AlertDialog class, which is extended by more specific dialog classes: ● DatePickerDialog ● ProgressDialog ● TimePickerDialog In this tutorial we will create AlertDialogs using the AlertDialog.Builder helper class. AlertDialogs are divided into the following components: ● Title Area ● Content Area ● Buttons - Positive, negative and neutral None of the components are mandatory, and for each components there is a default view. In this tutorial we will see 3 examples: ● Single-Choice Dialog ● Dialog with buttons
  • 3. Single-Choice Dialog This example uses the following default components: ● Title Area - The default title view which is actually a TextView. The view is set using the setTitle() method of the AlertDialog.Builder class. ● Content Area - The default single-choice ListView which is actually a RadioGroup. The view is set using the setSingleChoiceItems() method of the AlertDialog.Builder class. The AlertDialog in this example is created using the following code: 1. builder = new AlertDialog.Builder(mContext); 2. builder.setTitle(R.string.dialog_single_choice_title); 3. builder.setSingleChoiceItems(R.array.color_names, mSingleChoicePosition, this); 4. mAlertDialog = builder.create(); 5. mAlertDialog.show(); The color_names array is described in the res/values/color_names.xml file below: 1. <?xml version="1.0" encoding="utf-8"?> 2. <resources>
  • 4. Dialog With Buttons This example uses the following default components: ● Title Area - The default title view which is actually a TextView. The view is set using the setTitle() method of the AlertDialog.Builder class. ● Content Area - The default message view which is actually a TextView. The view is set using the setMessage() method of the AlertDialog.Builder class. ● Buttons - Positive and Negative buttons are set using the setPositiveButton() and setNegativeButton() methods of the AlertDialog.Builder class. The AlertDialog in this example is created using the following code: 1. builder = new AlertDialog.Builder(mContext); 2. builder.setTitle(R.string.dialog_with_buttons_title); 3. builder.setMessage(R.string.dialog_with_buttons_message); 4. builder.setPositiveButton(R.string.dialog_with_buttons_positive, this);
  • 5. Custom Dialog This example uses only the content component, for the following res/layout/custom_dialog.xml file is used: 1. <?xml version="1.0" encoding="utf-8"?> 2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 3. android:layout_width="match_parent" 4. android:layout_height="match_parent" > 5. 6. <TextView android:id="@+id/tvTitle" 7. android:layout_width="match_parent" 8. android:layout_height="wrap_content" 9. android:padding="5dp" 10. android:text="@string/dialog_custom_title" 11. android:textAppearance="@android:style/TextAppearance.Medium.Inverse"
  • 6. Custom Dialog 1. <TextView android:id="@+id/tvContent" 2. android:layout_width="match_parent" 3. android:layout_height="wrap_content" 4. android:layout_below="@id/tvTitle" 5. android:text="@string/dialog_custom_text" 6. android:textAppearance="@android:style/TextAppearance.Large" 7. android:gravity="center" 8. android:textStyle="bold|italic" 9. android:paddingTop="20dp" 10. android:paddingBottom="20dp" /> 11. 12. <RatingBar android:id="@+id/ratingBar"
  • 7. Custom Dialog The AlertDialog in this example is created using the following code: 1. LayoutInflater inflater = LayoutInflater.from(mContext); 2. builder = new AlertDialog.Builder(mContext); 3. builder.setTitle(null); 4. View customDialogView = inflater.inflate(R.layout.custom_dialog, null, false); 5. RatingBar ratingBar = (RatingBar) customDialogView.findViewById(R.id.ratingBar); 6. ratingBar.setRating(mRating); 7. ratingBar.setOnRatingBarChangeListener(this); 8. builder.setView(customDialogView); 9. mAlertDialog = builder.create(); 10. mAlertDialog.show();