Skip to content

Instantly share code, notes, and snippets.

@codeforfun-jp
Created December 20, 2023 12:38
Show Gist options
  • Save codeforfun-jp/6d0471a87b938a8faa7d89261607c38f to your computer and use it in GitHub Desktop.
Save codeforfun-jp/6d0471a87b938a8faa7d89261607c38f to your computer and use it in GitHub Desktop.
Android Studio AlertDialog Customize - Java
public class MyDialogFragment extends DialogFragment {
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
// タイトル
TextView titleView = new TextView(getActivity());
titleView.setText("タイトル");
titleView.setTextSize(24);
titleView.setTextColor(Color.WHITE);
titleView.setBackgroundColor(getResources().getColor(R.color.blue));
titleView.setPadding(20, 20, 20, 20);
titleView.setGravity(Gravity.CENTER);
return new AlertDialog.Builder(requireActivity())
.setCustomTitle(titleView)
.setMessage("ここにメッセージを入力します。ここにメッセージを入力します。ここにメッセージを入力します。")
.setPositiveButton("OK", (dialog, id) -> {
})
.create();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment