Posted By

OyoKooN on 03/15/11


Tagged

java dialog android


Versions (?)

Dialog managing


 / Published in: Java
 

  1. protected Dialog onCreateDialog(int id) {
  2. Dialog dialog;
  3. AlertDialog.Builder builder;
  4. switch(id) {
  5. case ADD_ACCOUNT_DIALOG:
  6. dialog = ProgressDialog.show(AddAccountActivity.this, "", getResources().getText(R.string.wait_message), true);
  7. break;
  8. case ERROR_NAME_DIALOG:
  9. builder = new AlertDialog.Builder(AddAccountActivity.this);
  10. builder.setMessage(getResources().getText(R.string.account_name_error))
  11. .setCancelable(false)
  12. .setPositiveButton(getResources().getText(R.string.account_error_button), new DialogInterface.OnClickListener() {
  13. public void onClick(DialogInterface dialog, int id) {
  14. dialog.cancel();
  15. accountName.requestFocus();
  16. }
  17. });
  18. dialog = builder.create();
  19. break;
  20. case ERROR_API_KEY_DIALOG:
  21. builder = new AlertDialog.Builder(AddAccountActivity.this);
  22. builder.setMessage(getResources().getText(R.string.account_api_key_error))
  23. .setCancelable(false)
  24. .setPositiveButton(getResources().getText(R.string.account_error_button), new DialogInterface.OnClickListener() {
  25. public void onClick(DialogInterface dialog, int id) {
  26. dialog.cancel();
  27. accountApiKey.requestFocus();
  28. }
  29. });
  30. dialog = builder.create();
  31. break;
  32. case ERROR_CREDENTIALS_DIALOG:
  33. builder = new AlertDialog.Builder(AddAccountActivity.this);
  34. builder.setMessage(getResources().getText(R.string.account_credentials_error))
  35. .setCancelable(false)
  36. .setPositiveButton(getResources().getText(R.string.account_error_button), new DialogInterface.OnClickListener() {
  37. public void onClick(DialogInterface dialog, int id) {
  38. dialog.cancel();
  39. accountName.requestFocus();
  40. }
  41. });
  42. dialog = builder.create();
  43. break;
  44. default:
  45. dialog = null;
  46. }
  47. return dialog;
  48. }

Report this snippet  

You need to login to post a comment.