Skip to content

Instantly share code, notes, and snippets.

@koifish082
Created October 15, 2018 08:48
Show Gist options
  • Save koifish082/8f8cd6163858c45837c1fade5fc31a00 to your computer and use it in GitHub Desktop.
Save koifish082/8f8cd6163858c45837c1fade5fc31a00 to your computer and use it in GitHub Desktop.
public class DialogUtils {
public static void showOkButtonDialog(Context context, String message) {
View view = LayoutInflater.from(context).inflate(R.layout.view_alert_dialog, null, false);
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(context);
builder.setView(view);
android.app.AlertDialog alert = builder.create();
ColorDrawable back = new ColorDrawable(android.graphics.Color.TRANSPARENT);
InsetDrawable inset = new InsetDrawable(back, 100);
alert.getWindow().setBackgroundDrawable(inset);
TextView txtText = view.findViewById(R.id.tv_dialog_content);
txtText.setText(message);
TextView button = view.findViewById(R.id.tv_dialog_positive);
button.setOnClickListener(v -> alert.dismiss());
alert.show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment