SimpleMessageDialogFragment.java 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. package epson.print;
  2. import android.app.AlertDialog;
  3. import android.app.Dialog;
  4. import android.content.DialogInterface;
  5. import android.os.Bundle;
  6. public class SimpleMessageDialogFragment extends DialogFragment {
  7. private static final String PARAM_MESSAGE_RESOURCE_ID = "message_id";
  8. private int mMessageId;
  9. public static SimpleMessageDialogFragment newInstance(int i) {
  10. SimpleMessageDialogFragment simpleMessageDialogFragment = new SimpleMessageDialogFragment();
  11. Bundle bundle = new Bundle();
  12. bundle.putInt(PARAM_MESSAGE_RESOURCE_ID, i);
  13. simpleMessageDialogFragment.setArguments(bundle);
  14. return simpleMessageDialogFragment;
  15. }
  16. public void onCreate(Bundle bundle) {
  17. super.onCreate(bundle);
  18. mMessageId = getArguments().getInt(PARAM_MESSAGE_RESOURCE_ID);
  19. }
  20. @NonNull
  21. public Dialog onCreateDialog(Bundle bundle) {
  22. super.onCreateDialog(bundle);
  23. AlertDialog create = new AlertDialog.Builder(getActivity()).setMessage(mMessageId).setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() {
  24. public void onClick(DialogInterface dialogInterface, int i) {
  25. }
  26. }).create();
  27. create.setCanceledOnTouchOutside(false);
  28. return create;
  29. }
  30. }