Я нашел решение!Это то, что я сделал, на случай, если кому-то это понадобится.
@Override
protected Dialog onCreateDialog(int id) {//creates the dialog
final Dialog dialog = new Dialog(this);
dialog.requestWindowFeature( Window.FEATURE_CUSTOM_TITLE );//adds in the dialog box a frame for the custom title
@Override
protected Dialog onCreateDialog(int id) {//creates the dialog
final Dialog dialog = new Dialog(this);
dialog.requestWindowFeature( Window.FEATURE_CUSTOM_TITLE );//adds in the dialog box a frame for the custom title
//dialog.setTitle("New Contact");//sets the title of the dialog box
dialog.setContentView(R.layout.pop_up_new_contact);//loads the layout we have already create pop_up_new_contact.xml
dialog.getWindow().setFeatureInt( Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title_dialog_box);//sets our custom title(custom_title_dialog_box.xml) as the current title of the dialog box. The custom_title_dialog_box.xml contains a TextView with id: title_new_contact and an ImageView with id: x1_button.
dialog.setCancelable(true);//close the dialog box when the back key is pushed.
ImageView x1_button = (ImageView)dialog.findViewById(R.id.x1_button);
x1_button.setOnClickListener(new View.OnClickListener(){
public void onClick(View View3) {
dialog.dismiss();
}
});
return dialog;
}
Возможно, это не лучшее решение, но, по крайней мере, оно работает!