Как мне создать такой мини-макет в Android Studio? - PullRequest

Ответы [ 2 ]

0 голосов
/ 30 ноября 2018

попробуйте

/* using sign out alert for app*/
private void dialogBox() {
    android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(getActivity());
    String titleText = "Share using Wi-Fi Direct?";
    ForegroundColorSpan foregroundColorSpan = new ForegroundColorSpan(Color.BLACK);
    SpannableStringBuilder ssBuilder = new SpannableStringBuilder(titleText);
    ssBuilder.setSpan(
            foregroundColorSpan,
            0,
            titleText.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
    );
    builder.setCancelable(false);
    builder.setTitle(ssBuilder);

        builder.setMessage("You can only share folders using Wi-Fi Direct");


    builder.setPositiveButton("SHARE VIA WI-FI DIRECT", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
           // your code
        }
    });
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    // Create the alert dialog
    android.support.v7.app.AlertDialog dialog = builder.create();
    // Finally, display the alert dialog
    dialog.show();
    // Get the alert dialog buttons reference
    Button positiveButton = dialog.getButton(android.support.v7.app.AlertDialog.BUTTON_POSITIVE);
    Button negativeButton = dialog.getButton(AlertDialog.BUTTON_NEGATIVE);
    // Change the alert dialog buttons text and background color
    positiveButton.setTextColor(Color.parseColor("#00aff1"));
    negativeButton.setTextColor(Color.parseColor("#00aff1"));
}
  • вы используете диалоговое окно оповещения и настраиваемое диалоговое окно для отображения мини-макета на экране ниже

    enter image description here

надеюсь, это поможет вам

0 голосов
/ 30 ноября 2018

Я думаю, что вы пытаетесь сделать это диалоговое окно оповещения ... так что-то вроде этого

new AlertDialog.Builder(this)
                    .setTitle("Share using Wi-Fi Direct?")
                    .setCancelable(false)
                    .setMessage("You can only share folders using Wi-Fi Direct")
                    .setPositiveButton("SHARE VIA WI-FI DIRECT", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            //do what you want here
                        }
                    })
                    .setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            //do what you want here
                            finish();
                        }
                    })
                    .create()
                    .show();
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...