Example usage for android.app AlertDialog.Builder setView

List of usage examples for android.app AlertDialog.Builder setView

Introduction

In this page you can find the example usage for android.app AlertDialog.Builder setView.

Prototype

public void setView(View view) 

Source Link

Document

Set the view to display in that dialog.

Usage

From source file:com.example.tahsi.challenge.FreeCombDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = getActivity().getLayoutInflater();
    if (getArguments().getInt("type") == 1) {
        if (view == null) {
            view = inflater.inflate(R.layout.popup_free, null);
            viewHolder = new ViewHolder();
            viewHolder.AttrFree1 = (TextView) view.findViewById(R.id.attribute1);
            viewHolder.AttrFree2 = (TextView) view.findViewById(R.id.attribute2);
            viewHolder.freeEdit1 = (EditText) view.findViewById(R.id.editAttr1);
            viewHolder.freeEdit1.setTextColor(getActivity().getResources().getColor(R.color.editText));
            viewHolder.freeEdit2 = (EditText) view.findViewById(R.id.editAttr2);
            viewHolder.freeEdit2.setTextColor(getActivity().getResources().getColor(R.color.editText));
            view.setTag(viewHolder);/*w  w  w.  ja va 2 s  .  c  om*/
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }
    }
    if (getArguments().getInt("type") == 2) {
        if (view == null) {
            view = inflater.inflate(R.layout.popup_comb, null);
            viewHolder = new ViewHolder();
            viewHolder.AttrComb1 = (TextView) view.findViewById(R.id.attributeComb1);
            viewHolder.AttrComb2 = (TextView) view.findViewById(R.id.attributeComb2);
            viewHolder.comb = (EditText) view.findViewById(R.id.editAttrComb1);
            viewHolder.comb.setTextColor(getActivity().getResources().getColor(R.color.editText));
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }
    }

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity(), R.style.MyCustomTheme);
    if (getArguments().getInt("type") == 1) {
        if (getArguments().getInt("flag") == 1) {
            viewHolder.AttrFree1.setText(getArguments().getString("Attribute1"));
            viewHolder.AttrFree2.setText(getArguments().getString("Attribute2"));
            alertDialogBuilder.setView(view);
        } else if (getArguments().getInt("flag") == 2) {
            viewHolder.AttrFree1.setText(getArguments().getString("Attribute1"));
            viewHolder.AttrFree2.setText(getArguments().getString("Attribute2"));
            viewHolder.freeEdit1.setText(getArguments().getString("edit1"));
            viewHolder.freeEdit2.setText(getArguments().getString("edit2"));
            alertDialogBuilder.setView(view);
        }
    }
    if (getArguments().getInt("type") == 2) {
        if (getArguments().getInt("flag") == 1) {
            viewHolder.AttrComb1.setText(getArguments().getString("Attribute1"));
            viewHolder.AttrComb2.setText(getArguments().getString("Attribute2"));
            alertDialogBuilder.setView(view);
        } else if (getArguments().getInt("flag") == 2) {
            viewHolder.AttrComb1.setText(getArguments().getString("Attribute1"));
            viewHolder.AttrComb2.setText(getArguments().getString("Attribute2"));
            viewHolder.comb.setText(getArguments().getString("editcomb"));
            alertDialogBuilder.setView(view);
        }
    }

    alertDialogBuilder.setPositiveButton(R.string.dialogPos, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (getArguments().getInt("type") == 1) {
                mCallback.button(1,
                        viewHolder.freeEdit1.getText().toString().trim() + "/"
                                + viewHolder.freeEdit2.getText().toString().trim(),
                        viewHolder.AttrFree1.getText().toString().trim(),
                        viewHolder.AttrFree2.getText().toString().trim());
                ((ViewGroup) view.getParent()).removeView(view);
            } else if (getArguments().getInt("type") == 2) {
                if (getArguments().getInt("flag") == 1) {
                    values.put(AppContract.ChallengeEntry.COLUMN_CHALLENGE,
                            getArguments().getString("Challenge"));
                    values.put(AppContract.ChallengeEntry.COLUMN_ATTRIBUTE_PAIR,
                            getArguments().getString("Attribute1") + "/"
                                    + getArguments().getString("Attribute2"));
                    values.put(AppContract.ChallengeEntry.COLUMN_COMBINED,
                            viewHolder.comb.getText().toString().trim());
                    values.put(AppContract.ChallengeEntry.COLUMN_FREE, getArguments().getString("free"));
                    getActivity().getContentResolver().insert(AppContract.ChallengeEntry.CONTENT_URI_FREECOMB,
                            values);
                    values.clear();
                    dismiss();
                    ((ViewGroup) view.getParent()).removeView(view);

                } else if (getArguments().getInt("flag") == 2) {
                    values.put(AppContract.ChallengeEntry.COLUMN_COMBINED,
                            viewHolder.comb.getText().toString().trim());
                    values.put(AppContract.ChallengeEntry.COLUMN_FREE, getArguments().getString("free"));
                    int answerupdate = getActivity().getContentResolver()
                            .update(AppContract.ChallengeEntry.CONTENT_URI_FREECOMB, values,
                                    AppContract.ChallengeEntry.COLUMN_CHALLENGE + " LIKE '%"
                                            + getArguments().getString("Challenge") + "%' COLLATE NOCASE",
                                    null);
                    values.clear();
                    dismiss();
                    ((ViewGroup) view.getParent()).removeView(view);
                }
            }
        }
    });
    alertDialogBuilder.setNegativeButton(R.string.dialogNeg, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    return alertDialogBuilder.create();
}

From source file:it.mb.whatshare.Dialogs.java

/**
 * Shows the about screen./*from w  ww .  ja v  a2s.  c o  m*/
 * 
 * @param activity
 *            the caller activity
 */
public static void showAbout(final FragmentActivity activity) {
    DialogFragment dialog = new PatchedDialogFragment() {
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            AlertDialog.Builder builder = getBuilder(activity);
            View layout = View.inflate(getContext(), R.layout.about, null);
            String version = "alpha";
            try {
                version = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0).versionName;
            } catch (NameNotFoundException e) {
                e.printStackTrace();
            }
            ((TextView) layout.findViewById(R.id.title))
                    .setText(activity.getResources().getString(R.string.title_about_dialog, version));
            ((TextView) layout.findViewById(R.id.build_date)).setText(
                    activity.getResources().getString(R.string.build_date_about, getBuildDate(activity)));
            // make links clickable
            ((TextView) layout.findViewById(R.id.description))
                    .setMovementMethod(LinkMovementMethod.getInstance());
            builder.setView(layout);
            return builder.create();
        }
    };
    dialog.show(activity.getSupportFragmentManager(), "about");
}

From source file:edu.missouri.niaaa.ema.activity.AdminManageActivity.java

private Dialog assignConfirmDialog(Context context, String str, boolean startNewWeek) {

    LayoutInflater inflater = LayoutInflater.from(context);
    final View textEntryView = inflater.inflate(R.layout.remove_id, null);
    final CheckBox rm_check = (CheckBox) textEntryView.findViewById(R.id.rm_local);
    rm_check.setText(R.string.assign_new_week);
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    if (startNewWeek) {
        builder.setView(textEntryView);
    }//from w ww  .ja va 2 s .  c  om
    builder.setCancelable(false);
    builder.setTitle(R.string.assign_confirm_title);
    builder.setMessage(str);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {
            editor.putString(Utilities.SP_KEY_LOGIN_USERID, asID.getText().toString());
            Log.d("here!!!", "id is " + asID.getText().toString());
            //format check

            editor.putString(Utilities.SP_KEY_LOGIN_USERPWD, "");
            editor.putString(Utilities.SP_KEY_LOGIN_STUDY_STARTTIME,
                    "" + Calendar.getInstance().getTimeInMillis());
            editor.commit();

            //start new study week, if checked
            if (rm_check.isChecked()) {

                String UID = null;
                try {
                    UID = Utilities.encryption(asID.getText().toString());
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

                ChangeStudyWeek changeStudyWeek = new ChangeStudyWeek();
                changeStudyWeek.execute(UID);
            }

            setHints();
            //continue with set user pin (8)
            setResult(Activity.RESULT_OK);
            finish();
        }
    });

    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub
            setHints();
        }
    });
    return builder.create();
}

From source file:azad.hallaji.farzad.com.masirezendegi.PageVirayesh.java

private void jostaruzunueymahziba(String message) {

    LayoutInflater inflater = this.getLayoutInflater();
    View dialogView = inflater.inflate(R.layout.alert_dialog_login, null);

    final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
    dialogBuilder.setView(dialogView);

    TextView textView = (TextView) dialogView.findViewById(R.id.aaT);
    TextView textVie = (TextView) dialogView.findViewById(R.id.aT);
    textView.setText(message);/*from  w  w  w.ja v a  2  s. co m*/
    textVie.setVisibility(View.INVISIBLE);
    Button button = (Button) dialogView.findViewById(R.id.buttombastan);
    final AlertDialog alertDialog = dialogBuilder.create();
    alertDialog.show();

    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            alertDialog.cancel();
            /*Intent intent = new Intent(PageVirayesh.this,PageVirayesh.class);
            startActivity(intent);*/

        }
    });

}

From source file:edu.missouri.niaaa.pain.activity.AdminManageActivity.java

private Dialog assignConfirmDialog(final Context context, String str, boolean startNewWeek) {

    LayoutInflater inflater = LayoutInflater.from(context);
    final View textEntryView = inflater.inflate(R.layout.remove_id, null);
    final CheckBox rm_check = (CheckBox) textEntryView.findViewById(R.id.rm_local);
    rm_check.setText(R.string.assign_new_week);
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    if (startNewWeek) {
        builder.setView(textEntryView);
    }/*  www  .  j  a va  2 s .  c o  m*/
    builder.setCancelable(false);
    builder.setTitle(R.string.assign_confirm_title);
    builder.setMessage(str);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {
            editor.putString(Util.SP_LOGIN_KEY_USERID, asID.getText().toString());
            Log.d("here!!!", "id is " + asID.getText().toString());
            //format check

            editor.putString(Util.SP_LOGIN_KEY_USERPWD, "");
            editor.putString(Util.SP_LOGIN_KEY_STUDY_STARTTIME, "" + Calendar.getInstance().getTimeInMillis());
            editor.commit();

            //start new study week, if checked
            if (rm_check.isChecked()) {

                String UID = null;
                try {
                    UID = Util.encryption(context, asID.getText().toString());
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

                ChangeStudyWeek changeStudyWeek = new ChangeStudyWeek();
                changeStudyWeek.execute(UID);
            }

            setHints();
            //continue with set user pin (8)
            setResult(Activity.RESULT_OK);
            finish();
        }
    });

    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub
            setHints();
        }
    });
    return builder.create();
}

From source file:com.chaturs.notepad.NoteEditor.java

private void showDialogForTitle() {

    View view = LayoutInflater.from(this).inflate(R.layout.dialog_title, null);
    final EditText edit = (EditText) view.findViewById(R.id.edit);
    Button okButton = (Button) view.findViewById(R.id.ok);
    Button cancelButton = (Button) view.findViewById(R.id.cancel);

    edit.setText(title);/*www . j  ava2  s  . c  om*/
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Enter Title");
    builder.setView(view);
    builder.setCancelable(false);

    okButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            title = edit.getText().toString();

            if (title.trim().length() == 0) {
                edit.setError("Please Enter Some Text !");
                return;
            }

            saveNote();
            setTitle(title);
            dialog.dismiss();
        }
    });

    cancelButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            dialog.dismiss();

        }
    });

    dialog = builder.create();
    dialog.show();
}

From source file:ca.uwaterloo.magic.goodhikes.AddMilestoneDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    mapsActivity = (MapsActivity) getActivity();
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View dialog = inflater.inflate(R.layout.dialog_add_milestone, null);
    previewImage = (ImageView) dialog.findViewById(R.id.previewImage);

    if (savedInstanceState != null) {
        Bitmap image = savedInstanceState.getParcelable("image");
        if (image != null) {
            previewImage.setImageBitmap(image);
        }//from   w w w  . ja  v a  2 s.c  o  m
    }

    builder.setView(dialog).setTitle(R.string.add_milestone)
            .setPositiveButton(R.string.add, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    EditText noteField = (EditText) ((Dialog) dialog).findViewById(R.id.note);
                    String note = noteField.getText().toString();
                    Bitmap image = previewImage.getDrawable() == null ? null
                            : ((BitmapDrawable) previewImage.getDrawable()).getBitmap();

                    mapsActivity.imageSelected(image, note);
                    Toast.makeText(getActivity(), "Milestone added", Toast.LENGTH_SHORT).show();
                    Log.d(LOG_TAG, "Thread: " + Thread.currentThread().getId() + "; milestone added");
                }
            }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    Log.d(LOG_TAG, "Thread: " + Thread.currentThread().getId() + "; milestone cancelled");
                }
            });

    Button addImageButton = (Button) dialog.findViewById(R.id.addImageButton);
    addImageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Create intent to Open Image applications like Gallery, Google Photos
            Intent galleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
            startActivityForResult(galleryIntent, RESULT_LOAD_IMG);
        }
    });

    Button cameraButton = (Button) dialog.findViewById(R.id.cameraButton);
    cameraButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Create intent to open device's Camera
            Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(cameraIntent, RESULT_CAPTURE_IMG);
        }
    });

    return builder.create();
}

From source file:com.example.moneymeterexample.AddExpenseActivity.java

protected Dialog onCreateDialog(int id) {

    switch (id) {
    case DATE_DIALOG_ID:
        return new DatePickerDialog(this, pDateSetListener, mYear, mMonth, mDay);

    case NEW_CATEGORY_ID:
        AlertDialog.Builder new_cat_dialog = new AlertDialog.Builder(this);
        new_cat_dialog.setMessage("Enter the name of new category");
        new_cat_dialog.setTitle("New Category");
        final EditText new_cat_txt = new EditText(this);
        new_cat_dialog.setView(new_cat_txt);
        new_cat_dialog.setPositiveButton("Ok", new DialogInterface.OnClickListener() {

            @Override//from ww w .j a  va 2  s .c o  m
            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                String cat = new_cat_txt.getText().toString();

                String last = cat_list.remove((cat_list.size()) - 1);
                cat_list.add(cat);
                cat_list.add(last);
                ((BaseAdapter) category.getAdapter()).notifyDataSetChanged();

            }
        });
        new_cat_dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                dialog.cancel();

            }
        });

        return new_cat_dialog.create();

    case DELETE_CONFIRM_ID:
        AlertDialog.Builder delete_dialog = new AlertDialog.Builder(this);
        delete_dialog.setMessage("Are you sure you want to delete this entry?");
        delete_dialog.setTitle("Delete Confirmation");
        delete_dialog.setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                deleteRecord();
                amt.setText("");
                date.setText("");
                cat_list.remove(category.getSelectedItem().toString());
                ((BaseAdapter) category.getAdapter()).notifyDataSetChanged();
                notes.setText("");

            }
        });
        delete_dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                dialog.cancel();

            }
        });

        return delete_dialog.create();

    }
    return null;
}

From source file:com.cypress.cysmart.RDKEmulatorView.MicrophoneEmulatorFragment.java

/**
 * Method to display a custom alert.//  w ww. j a  v  a2  s  .com
 * Option for entering the google key in the method for voice to
 * text conversion
 */
private void showCustumAlert(String storedKey, boolean changeNeeded) {

    LayoutInflater li = LayoutInflater.from(getActivity());
    View promptsView = li.inflate(R.layout.api_key_dialog_alert, null);
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());

    // set api_key_dialog_alert.xml to alertdialog builder
    alertDialogBuilder.setView(promptsView);

    //User input Edittext
    final EditText userInput = (EditText) promptsView.findViewById(R.id.custom_alert_user_input);
    if (changeNeeded) {
        userInput.setText(storedKey);
    }

    // set dialog message
    alertDialogBuilder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            // get user input and set it to sharedpreferecne
            Logger.i("userInput.getText()--->" + userInput.getText());
            Utils.setStringSharedPreference(getActivity(), Constants.PREF_GOOGLE_API_KEY,
                    userInput.getText().toString());
        }
    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });

    // create alert dialog
    AlertDialog alertDialog = alertDialogBuilder.create();

    // show it
    alertDialog.show();

}

From source file:com.example.parkhere.seeker.SeekerProfileVehicleFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    user = (User) getArguments().getSerializable(USER_KEY);
    vehicles = (Vehicle[]) getArguments().getSerializable(SEEKER_VEHICLES_KEY);

    getCurrInfo();// w  w  w  .  j  av a 2  s.  c o m

    rootView = inflater.inflate(R.layout.fragment_seeker_profile_vehicle, container, false);

    sprof_make = (EditText) rootView.findViewById(R.id.sprof_make);
    sprof_model = (EditText) rootView.findViewById(R.id.sprof_model);
    sprof_color = (EditText) rootView.findViewById(R.id.sprof_color);
    sprof_year = (EditText) rootView.findViewById(R.id.sprof_year);
    sprof_licenseplate = (EditText) rootView.findViewById(R.id.sprof_licenseplate);

    tl = (TableLayout) rootView.findViewById(R.id.sprof_vehicle_table);

    sprof_add_vehicle_button = (Button) rootView.findViewById(R.id.sprof_add_vehicle_button);
    sprof_edit_vehicle_button = (Button) rootView.findViewById(R.id.sprof_edit_vehicle_button);
    sprof_delete_vehicle_button = (Button) rootView.findViewById(R.id.sprof_delete_vehicle_button);

    sprof_add_vehicle_button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            String make = sprof_make.getText().toString();
            String model = sprof_model.getText().toString();
            String color = sprof_color.getText().toString();
            String year = sprof_year.getText().toString();
            String licensePlate = sprof_licenseplate.getText().toString();

            Vehicle vehicle = new Vehicle();
            vehicle.setMake(make);
            vehicle.setModel(model);
            vehicle.setColor(color);
            vehicle.setYear(year);
            vehicle.setLicensePlate(licensePlate);

            if (!validate(vehicle)) {
                onAddUpdateVehicleFailed();
                return;
            }

            Vehicle v = getVehicle(licensePlate);
            if (v.getMake() == null) {
                addVehicle(vehicle);
            } else {
                Snackbar.make(rootView, "Vehicle with this license plate already exists; cannot re-add",
                        Snackbar.LENGTH_LONG).show();
            }
        }
    });

    sprof_edit_vehicle_button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            if (selectedMake.equals("")) {
                Snackbar.make(rootView, "Must select a vehicle", Snackbar.LENGTH_LONG).show();
            } else {
                String make = sprof_make.getText().toString();
                String model = sprof_model.getText().toString();
                String color = sprof_color.getText().toString();
                String year = sprof_year.getText().toString();
                String licensePlate = sprof_licenseplate.getText().toString();

                Vehicle vehicle = new Vehicle();
                vehicle.setMake(make);
                vehicle.setModel(model);
                vehicle.setColor(color);
                vehicle.setYear(year);
                vehicle.setLicensePlate(licensePlate);

                if (!validate(vehicle)) {
                    onAddUpdateVehicleFailed();
                    return;
                } else if (!licensePlate.equals(selectedLicensePlate)) {
                    Snackbar.make(rootView,
                            "Cannot update vehicle license plate; add a new vehicle with this license plate",
                            Snackbar.LENGTH_LONG).show();
                } else {
                    vehicles[selectedIndex - 1] = vehicle;
                    TableRow tr = (TableRow) tl.findViewWithTag(selectedIndex);
                    tr.setBackgroundColor(Color.LTGRAY);
                    TextView tv = (TextView) tr.getChildAt(0);
                    tv.setText(vehicle.getMake());
                    tv = (TextView) tr.getChildAt(1);
                    tv.setText(vehicle.getModel());
                    editVehicle();
                }
            }
        }
    });

    sprof_delete_vehicle_button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            if (selectedMake.equals("")) {
                Snackbar.make(rootView, "Must select a vehicle", Snackbar.LENGTH_LONG).show();
            } else if (tag == 2) {
                Snackbar.make(rootView, "Must add another vehicle before deleting your only listed vehicle",
                        Snackbar.LENGTH_LONG).show();
            } else {
                LayoutInflater li = LayoutInflater.from(myContext);
                View customView = li.inflate(R.layout.popup_delete_vehicle, null);

                AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(myContext);
                alertDialogBuilder.setView(customView);
                final AlertDialog alertDialog = alertDialogBuilder.create();

                TextView deleteText = (TextView) customView.findViewById(R.id.popup_delete_vehicle_text);
                deleteText.setText("Are you sure you want to delete this vehicle: " + selectedMake + " "
                        + selectedModel + " " + selectedLicensePlate + "?");

                ImageButton closeButton = (ImageButton) customView
                        .findViewById(R.id.popup_delete_vehicle_close);
                closeButton.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        alertDialog.dismiss();
                    }
                });

                Button deleteButton = (Button) customView.findViewById(R.id.popup_delete_vehicle_button);
                deleteButton.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        deleteVehicle();
                        alertDialog.dismiss();
                    }
                });

                alertDialog.show();
            }
        }
    });

    return rootView;
}