BottomSheetDialog Example Android

This post describes how to create and display a BottomSheetDialog on Button Click in android. Create your layout in activity_main.xml. Add a TextView for displaying date, and a Button for displaying BottomSheetDialog. Create dialog.xml. Set fixed height for root view and add a TextView and a Button. In MainActivity.java show BottomSheetDialog on button click. Now … Read more

Dialog with a single choice String List

This post describes how to display a String list in a dialog box and select one item from it. In activity_main.xml add a Button and a TextView. In MainActivity.java use following code. Now run the app. It will show the dialog box with list of fruits when button is clicked. And when any fruit is … Read more

AlertDialog with custom view

To create an AlertDialog with a custom view, we first have to create the custom view. Let us create a Custom View custom_dialog.xml containing a TextView, an ImageView and a Button. Now in the MainActivity or any other Activity, use following codes to display the custom_dialog.xml in an AlertDialog. That’s all. Try the code now … Read more

AlertDialog in android

A dialog is a small window which is displayed above the main UI, in a part of the screen. It normally requires users to take an action before they can proceed (e.g. confirm an action, select an option, read alert message, etc.). An AlertDialog has three regions:- This code below will display an AlertDialog with … Read more

Android TimePickerDialog

Here we will create a simple app which displays a TimePickerDialog on clicking an ImageView and displays the selected Time in a TextView. Step 1: Create a new project with name ‘Time Picker’ and package name com.myexample.appcompat.timepicker. Fill the forms and click “Finish” button. Step 2: In app level build.gradle add following dependencies: Step 3: In drawable folder add … Read more

Android DatePickerDialog

Here we will create a simple app which displays a DatePickerDialog on clicking an ImageView and displays the selected date in a TextView. Step 1: Create a new project with name ‘Date Picker’ and package name com.myexample.appcompat.picker. Fill the forms and click “Finish” button. Step 2: In app level build.gradle add following dependencies: Step 3: In drawable folder add … Read more