-3

I want to make a custom alert dialog such as this image what i will do to make that ? i want to design this dialogAlert Dialog

Yousry Badr
  • 21
  • 1
  • 5

1 Answers1

4

First of all you need to create a new layout xml file and a new layout for your title if you want custom title also.

 final AlertDialog dialog;

    final View alertDialogView = LayoutInflater.from(getContext()).inflate
            (R.layout.your_layout, null);
    final View titleView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_layout, null);

 dialog = new AlertDialog.Builder(getContext())
            .setView(alertDialogView)
            .setCustomTitle(titleView)
            .setPositiveButton(R.string.set, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                  ///do your job
            })
            .setCancelable(true)
            .create();


    dialog.show();

also if you want to access the title from custom layout you can access it in this way:

((TextView) titleView.findViewById(R.id.title)).setText(getString(R.string.
your_string));