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
Asked
Active
Viewed 5,680 times
-3
-
1what have you done so far ? Where is your code ? – Ahlem Jarrar Oct 19 '17 at 10:03
-
i want to design this dialog and i have no idea how to design it – Yousry Badr Oct 19 '17 at 10:13
1 Answers
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));

Aris Panayiotou
- 142
- 6