Tutorial by Examples

AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( MainActivity.this); alertDialogBuilder.setTitle("Title Dialog"); alertDialogBuilder .setMessage("Message Dialog") .setCancelable(true) ...
AlertDialog.Builder builder = new AlertDialog.Builder(context); //Set Title builder.setTitle("Reset...") //Set Message .setMessage("Are you sure?") //Set the icon of the dialog .setIcon(drawable) //Set...
xml of the Dialog: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="mat...
DatePickerDialog is the simplest way to use DatePicker, because you can show dialog anywhere in your app. You don't have to implement your own layout with DatePicker widget. How to show dialog: DatePickerDialog datePickerDialog = new DatePickerDialog(context, listener, year, month, day); datePick...
DatePicker allows user to pick date. When we create new instance of DatePicker, we can set initial date. If we don't set initial date, current date will be set by default. We can show DatePicker to user by using DatePickerDialog or by creating our own layout with DatePicker widget. Also we can ...
AlertDialog is a subclass of Dialog that can display one, two or three buttons. If you only want to display a String in this dialog box, use the setMessage() method. The AlertDialog from android.app package displays differently on different Android OS Versions. The Android V7 Appcompat library pro...
We can always use ListView or RecyclerView for selection from list of items, but if we have small amount of choices and among those choices we want user to select one, we can use AlertDialog.Builder setAdapter. private void showDialog() { AlertDialog.Builder builder = new AlertDia...
void alertDialogDemo() { // get alert_dialog.xml view LayoutInflater li = LayoutInflater.from(getApplicationContext()); View promptsView = li.inflate(R.layout.alert_dialog, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( ...
in styles.xml add your custom style: <?xml version="1.0" encoding="utf-8"?> <resources> <style name="AppBaseTheme" parent="@android:style/Theme.Light.NoTitleBar.Fullscreen"> </style> </resources> Create your custom...
The setCustomTitle() method of AlertDialog.Builder lets you specify an arbitrary view to be used for the dialog title. One common use for this method is to build an alert dialog that has a long title. AlertDialog.Builder builder = new AlertDialog.Builder(context, Theme_Material_Light_Dialog); buil...

Page 1 of 1