Skip to content

Instantly share code, notes, and snippets.

@codeforfun-jp
Created December 20, 2023 12:55
Show Gist options
  • Save codeforfun-jp/098e02efcfb8a0b6f0fa45bcebadc0bb to your computer and use it in GitHub Desktop.
Save codeforfun-jp/098e02efcfb8a0b6f0fa45bcebadc0bb 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) {
/* 省略 */
}
@Override
public void onStart() {
super.onStart();
AlertDialog alertDialog = (AlertDialog) getDialog();
if (alertDialog != null) {
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(Color.WHITE);
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setBackgroundColor(getResources().getColor(R.color.orange));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment