Java Code Examples for androidx.appcompat.app.AlertDialog#setCustomTitle()

The following examples show how to use androidx.appcompat.app.AlertDialog#setCustomTitle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivityGlobalAbstract.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void showInfoDialog(String title, String message) {
    if (getActivity() != null) {
        AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();

        //TITLE
        final View titleView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_title, null);
        ((TextView) titleView.findViewById(R.id.dialogTitle)).setText(title);
        alertDialog.setCustomTitle(titleView);

        //BODY
        final View msgView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_body, null);
        ((TextView) msgView.findViewById(R.id.dialogBody)).setText(message);
        msgView.findViewById(R.id.dialogAccept).setOnClickListener(view -> alertDialog.dismiss());
        msgView.findViewById(R.id.dialogCancel).setOnClickListener(view -> alertDialog.dismiss());
        alertDialog.setView(msgView);


        alertDialog.show();

    }
}
 
Example 2
Source File: ActivityGlobalAbstract.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public AlertDialog showInfoDialog(String title, String message, OnDialogClickListener clickListener) {
    if (getActivity() != null) {
        AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();

        //TITLE
        final View titleView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_title, null);
        ((TextView) titleView.findViewById(R.id.dialogTitle)).setText(title);
        alertDialog.setCustomTitle(titleView);

        //BODY
        final View msgView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_body, null);
        ((TextView) msgView.findViewById(R.id.dialogBody)).setText(message);
        msgView.findViewById(R.id.dialogAccept).setOnClickListener(view -> {
            clickListener.onPossitiveClick(alertDialog);
            alertDialog.dismiss();
        });
        msgView.findViewById(R.id.dialogCancel).setOnClickListener(view -> {
            clickListener.onNegativeClick(alertDialog);
            alertDialog.dismiss();
        });
        alertDialog.setView(msgView);

        return alertDialog;

    } else
        return null;
}
 
Example 3
Source File: ActivityGlobalAbstract.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public AlertDialog showInfoDialog(String title, String message, String positiveButtonText, String negativeButtonText, OnDialogClickListener clickListener) {
    if (getActivity() != null) {
        AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();

        //TITLE
        final View titleView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_title, null);
        ((TextView) titleView.findViewById(R.id.dialogTitle)).setText(title);
        alertDialog.setCustomTitle(titleView);

        //BODY
        final View msgView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_body, null);
        ((TextView) msgView.findViewById(R.id.dialogBody)).setText(message);
        ((Button) msgView.findViewById(R.id.dialogAccept)).setText(positiveButtonText);
        ((Button) msgView.findViewById(R.id.dialogCancel)).setText(negativeButtonText);
        msgView.findViewById(R.id.dialogAccept).setOnClickListener(view -> {
            clickListener.onPossitiveClick(alertDialog);
            alertDialog.dismiss();
        });
        msgView.findViewById(R.id.dialogCancel).setOnClickListener(view -> {
            clickListener.onNegativeClick(alertDialog);
            alertDialog.dismiss();
        });
        alertDialog.setView(msgView);

        return alertDialog;

    } else
        return null;
}