private void showFeedback(String msg) {
    AlertDialog.Builder builder = new AlertDialog.Builder(super.getActivity());
    builder.setTitle(super.getActivity().getString(R.string.feedback));
    builder.setMessage(msg);
    try {
      if (this.quiz.getCurrentQuestion().getScoreAsPercent() >= Quiz.QUIZ_QUESTION_PASS_THRESHOLD) {
        builder.setIcon(R.drawable.quiz_tick);
      } else {
        builder.setIcon(R.drawable.quiz_cross);
      }
    } catch (InvalidQuizException e) {
      e.printStackTrace();
    }
    builder.setPositiveButton(
        R.string.ok,
        new DialogInterface.OnClickListener() {

          public void onClick(DialogInterface arg0, int arg1) {
            if (QuizWidget.this.quiz.hasNext()) {
              QuizWidget.this.quiz.moveNext();
              QuizWidget.this.showQuestion();
            } else {
              QuizWidget.this.showResults();
            }
          }
        });
    builder.show();
    try {
      this.quiz.getCurrentQuestion().setFeedbackDisplayed(true);
    } catch (InvalidQuizException e) {
      e.printStackTrace();
    }
  }
Example #2
0
  /** Create AlertDialogs used on all the activity */
  private void initAllAlertDialogs() {
    Resources res = getResources();

    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    builder.setTitle(res.getString(R.string.connection_error_title));
    builder.setIcon(android.R.drawable.ic_dialog_alert);
    builder.setMessage(res.getString(R.string.connection_needed));
    builder.setPositiveButton(res.getString(R.string.ok), null);
    mNoConnectionAlert = builder.create();

    builder.setTitle(res.getString(R.string.log_in));
    builder.setIcon(android.R.drawable.ic_dialog_alert);
    builder.setMessage(res.getString(R.string.invalid_username_password));
    mInvalidUserPassAlert = builder.create();

    builder.setTitle(res.getString(R.string.connection_error_title));
    builder.setIcon(android.R.drawable.ic_dialog_alert);
    builder.setMessage(res.getString(R.string.connection_error_message));
    builder.setPositiveButton(
        res.getString(R.string.retry),
        new DialogInterface.OnClickListener() {

          public void onClick(DialogInterface dialog, int which) {
            login();
          }
        });
    builder.setNegativeButton(res.getString(R.string.cancel), null);
    mConnectionErrorAlert = builder.create();
  }
  @Override
  protected void onListItemClick(ListView parent, View view, int position, long id) {
    AlertDialog dialog;
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    CharSequence[] options = {"Kill", "Details", "Launch"};
    final int index = position;

    builder.setTitle("Process options");

    try {
      builder.setIcon(pk.getApplicationIcon(display_process.get(position).processName));

    } catch (NameNotFoundException e) {
      builder.setIcon(R.drawable.processinfo);
    }

    builder.setItems(
        options,
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int choice) {

            switch (choice) {
              case 0:
                //						Process.killProcess(display_process.get(index).pid);
                activity_man.restartPackage(display_process.get(index).processName);
                update_list(true);
                break;

              case 1:
                Toast.makeText(
                        ProcessManager.this,
                        display_process.get(index).processName,
                        Toast.LENGTH_SHORT)
                    .show();
                break;

              case 2:
                Intent i = pk.getLaunchIntentForPackage(display_process.get(index).processName);

                if (i != null) startActivity(i);
                else
                  Toast.makeText(ProcessManager.this, "Could not launch", Toast.LENGTH_SHORT)
                      .show();

                break;
            }
          }
        });

    dialog = builder.create();
    dialog.show();
  }
  /** Build and show a dialog for user input. Add user input to the white list. */
  private void addToWhiteList() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setCancelable(true);
    builder.setIcon(android.R.drawable.ic_input_add);
    builder.setTitle(getResources().getString(R.string.AdblockerWhiteListDialogAddTitle));

    builder.setInverseBackgroundForced(true);

    // Set an EditText view to get user input
    final EditText input = new EditText(this);
    input.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
    builder.setView(input);

    builder.setInverseBackgroundForced(true);
    builder.setPositiveButton(
        getResources().getString(R.string.OK),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            doAddToWhiteList(input.getText().toString());
          }
        });
    builder.setNegativeButton(
        getResources().getString(R.string.Cancel),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
          }
        });
    AlertDialog alert = builder.create();
    alert.show();
  }
  private void showEditDialog(final ViewHolder holder) {
    if (LOG) {
      MtkLog.v(TAG, "showEditDialog(" + holder + ")");
    }
    if (holder == null) {
      return;
    }
    final LayoutInflater inflater = LayoutInflater.from(this);
    final View v = inflater.inflate(R.layout.bookmark_edit_dialog, null);
    final EditText titleView = (EditText) v.findViewById(R.id.title);
    final EditText dataView = (EditText) v.findViewById(R.id.data);
    titleView.setText(holder.mTitle);
    dataView.setText(holder.mData);

    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.edit);
    builder.setView(v);
    builder.setIcon(R.drawable.ic_menu_display_bookmark);
    builder.setPositiveButton(
        android.R.string.ok,
        new OnClickListener() {

          @Override
          public void onClick(final DialogInterface dialog, final int which) {
            mBookmark.update(
                holder.mId, titleView.getText().toString(), dataView.getText().toString(), 0);
          }
        });
    builder.setNegativeButton(android.R.string.cancel, null);
    final AlertDialog dialog = builder.create();
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    dialog.setInverseBackgroundForced(true);
    dialog.show();
  }
  private void showLayoutSelectorDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setIcon(R.drawable.ic_mms_layout);

    String title = getResources().getString(R.string.layout_selector_title);
    builder.setTitle(title + (mPosition + 1) + "/" + mSlideshowModel.size());

    LayoutSelectorAdapter adapter = new LayoutSelectorAdapter(this);
    builder.setAdapter(
        adapter,
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            switch (which) {
              case 0: // Top text.
                mSlideshowEditor.changeLayout(LayoutModel.LAYOUT_TOP_TEXT);
                break;
              case 1: // Bottom text.
                mSlideshowEditor.changeLayout(LayoutModel.LAYOUT_BOTTOM_TEXT);
                break;
            }
            dialog.dismiss();
          }
        });

    builder.show();
  }
  /** Ask the user the file to import to bookmarks and history, and launch the import. */
  private void importHistoryBookmarks() {
    List<String> exportedFiles = IOUtils.getExportedBookmarksFileList();

    final String[] choices = exportedFiles.toArray(new String[exportedFiles.size()]);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setInverseBackgroundForced(true);
    builder.setIcon(android.R.drawable.ic_dialog_info);
    builder.setTitle(getResources().getString(R.string.Commons_ImportHistoryBookmarksSource));
    builder.setSingleChoiceItems(
        choices,
        0,
        new OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {

            doImportHistoryBookmarks(choices[which]);

            dialog.dismiss();
          }
        });

    builder.setCancelable(true);
    builder.setNegativeButton(R.string.Commons_Cancel, null);

    AlertDialog alert = builder.create();
    alert.show();
  }
Example #8
0
 /**
  * 发送App异常崩溃报告
  *
  * @param cont
  * @param crashReport
  */
 public static void sendAppCrashReport(final Context cont, final String crashReport) {
   AlertDialog.Builder builder = new AlertDialog.Builder(cont);
   builder.setIcon(android.R.drawable.ic_dialog_info);
   builder.setTitle(R.string.app_error);
   builder.setMessage(R.string.app_error_message);
   builder.setPositiveButton(
       R.string.submit_report,
       new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int which) {
           dialog.dismiss();
           // 发送异常报告
           Intent i = new Intent(Intent.ACTION_SEND);
           i.setType("text/plain"); // 模拟器
           // i.setType("message/rfc822") ; //真机
           i.putExtra(Intent.EXTRA_EMAIL, new String[] {"*****@*****.**"});
           i.putExtra(Intent.EXTRA_SUBJECT, "星宝宝Android客户端 - 错误报告");
           i.putExtra(Intent.EXTRA_TEXT, crashReport);
           cont.startActivity(Intent.createChooser(i, "发送错误报告"));
           Log.i("Exception Log", crashReport);
           // 退出
           AppManager.getAppManager().AppExit(cont);
         }
       });
   builder.setNegativeButton(
       R.string.sure,
       new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int which) {
           dialog.dismiss();
           // 退出
           AppManager.getAppManager().AppExit(cont);
         }
       });
   builder.show();
 }
  @Override
  public boolean onItemLongClick(AdapterView<?> arg0, View view, int position, long id) {
    ViewHolder holder = (ViewHolder) view.getTag();

    Txt01 = (String) holder.text01.getText();
    Txt02 = (String) holder.text02.getText();
    Txt03 = (String) holder.text03.getText();

    final AlertDialog.Builder dial = new AlertDialog.Builder(this);
    dial.setTitle("Suppression");
    dial.setIcon(R.drawable.ad_question);
    dial.setMessage("Confirmez vous la suppression du produit suivant: " + "" + Txt03);

    dial.setPositiveButton(
        "Ok",
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int id) {
            gotoSupprProduit(Txt01, Txt03);
          }
        });
    dial.setNegativeButton("Non", null);
    dial.show();
    return false;
  }
Example #10
0
  final void openGoogleShopper(String query) {

    // Construct Intent to launch Shopper
    Intent intent = new Intent(Intent.ACTION_SEARCH);
    intent.setClassName(GOOGLE_SHOPPER_PACKAGE, GOOGLE_SHOPPER_ACTIVITY);
    intent.putExtra(SearchManager.QUERY, query);

    // Is it available?
    PackageManager pm = activity.getPackageManager();
    Collection<?> availableApps =
        pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);

    if (availableApps != null && !availableApps.isEmpty()) {
      // If something can handle it, start it
      activity.startActivity(intent);
    } else {
      // Otherwise offer to install it from Market.
      AlertDialog.Builder builder = new AlertDialog.Builder(activity);
      builder.setTitle(R.string.msg_google_shopper_missing);
      builder.setMessage(R.string.msg_install_google_shopper);
      builder.setIcon(R.drawable.shopper_icon);
      builder.setPositiveButton(R.string.button_ok, shopperMarketListener);
      builder.setNegativeButton(R.string.button_cancel, null);
      builder.show();
    }
  }
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    Activity context = getActivity();
    int icon = R.drawable.ic_menu_delete;
    String title = getString(R.string.app_dialog_title_important);
    Spanned message = Html.fromHtml(getString(R.string.history_menu_remove_all_confirmation));
    String negativeBtn = getString(R.string.app_button_no);
    String positiveBtn = getString(R.string.app_button_yes);

    OnClickListener positiveOnClickListener =
        new OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            ((OnDeleteAllHistoryListener) onDeleteAllHistoryListener).onDeleteAllHistoryClicked();
          }
        };

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder
        .setIcon(icon)
        .setTitle(title)
        .setMessage(message)
        .setNegativeButton(negativeBtn, null)
        .setPositiveButton(positiveBtn, positiveOnClickListener);

    return builder.create();
  }
  @Override
  public void onBackPressed() {

    AlertDialog.Builder builder1 = new AlertDialog.Builder(PaymentmenuActivity.this);
    builder1.setMessage("Apakah anda akan melanjutkan transaksi?");
    builder1.setTitle("Confirm");
    builder1.setIcon(R.drawable.confirm);
    builder1.setCancelable(true);
    builder1.setPositiveButton(
        "Ya",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
            // Tutup dialog
            dialog.cancel();
          }
        });
    builder1.setNegativeButton(
        "Kembali Ke Awal",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
            // Kembali
            Intent intent = new Intent(PaymentmenuActivity.this, MainActivity.class);
            startActivity(intent);
          }
        });

    AlertDialog alert11 = builder1.create();
    alert11.show();
  }
Example #13
0
  private void login() {
    // TODO Auto-generated method stub
    if (session.isLoggedIn()) {
      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      builder.setTitle("Login");
      builder.setIcon(android.R.drawable.ic_dialog_alert);
      builder.setMessage("You are already connected!");
      builder.setPositiveButton(
          "ok",
          new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
              Intent i = new Intent(MainActivity.this, MainActivity.class);
              i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
              startActivity(i);
            }
          });
      AlertDialog alert = builder.create();
      alert.show();

    } else {
      Intent i = new Intent(MainActivity.this, LoginActivity.class);
      i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
      startActivity(i);
    }
  }
  private void showResetDialog() {

    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    builder.setIcon(R.drawable.warning);
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View layout = inflater.inflate(R.layout.about_screen, null);
    TextView aboutText = (TextView) layout.findViewById(R.id.aboutScreen);

    builder.setTitle(R.string.pref_profile_reset);

    aboutText.setText(R.string.pref_profile_reset_sum);

    builder
        .setView(layout)
        .setPositiveButton(
            R.string.got_it,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int id) {
                // Continue with resetting
                mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext);
                SharedPreferences.Editor editor = mPrefs.edit();
                editor.clear();
                editor.commit();
                Toast.makeText(mContext, R.string.successful, Toast.LENGTH_LONG).show();
              }
            })
        .setNegativeButton(
            R.string.maybe_later,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int id) {}
            });
    builder.show();
  }
Example #15
0
  public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
    if (arg2 == 0) {
      AlertDialog.Builder raumDialog = new AlertDialog.Builder(this);
      raumDialog.setTitle("Informationen zum Raum " + nummer);
      raumDialog.setMessage("Hier stehen alle Informationen zum Raum.");
      raumDialog.setNeutralButton(
          "ok",
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface arg0, int arg1) {}
          });
      raumDialog.show();
    }

    if (arg2 == 1) {
      AlertDialog.Builder raumDialog = new AlertDialog.Builder(this);
      raumDialog.setTitle("" + nummer);
      raumDialog.setIcon(R.drawable.raum_foto);
      raumDialog.setNeutralButton(
          "ok",
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface arg0, int arg1) {}
          });
      raumDialog.show();
    }

    if (arg2 == 2) {
      Intent intent = new Intent(CamNavSicht.this, WebSicht.class);
      startActivity(intent);
    }
    if (arg2 == 3) {
      flip.setDisplayedChild(2);
    }
  }
  private Dialog createRenameDialog() {
    final View layout = View.inflate(this, R.layout.dialog_rename, null);
    mInput = (EditText) layout.findViewById(R.id.name);
    ((TextView) layout.findViewById(R.id.label)).setText(R.string.gestures_rename_label);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setIcon(0);
    builder.setTitle(getString(R.string.gestures_rename_title));
    builder.setCancelable(true);
    builder.setOnCancelListener(
        new Dialog.OnCancelListener() {
          public void onCancel(DialogInterface dialog) {
            cleanupRenameDialog();
          }
        });
    builder.setNegativeButton(
        getString(R.string.cancel_action),
        new Dialog.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            cleanupRenameDialog();
          }
        });
    builder.setPositiveButton(
        getString(R.string.rename_action),
        new Dialog.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            changeGestureName();
          }
        });
    builder.setView(layout);
    return builder.create();
  }
Example #17
0
 // Adds existing contacts in your people application
 public void onClickPullContacts(View v) {
   AlertDialog.Builder alertDialogBuilder;
   alertDialogBuilder = new AlertDialog.Builder(this);
   // set title
   alertDialogBuilder.setTitle("Import Contacts?");
   alertDialogBuilder.setIcon(R.drawable.ic_action_refresh);
   // set dialog message
   alertDialogBuilder
       .setMessage("Do you want to import all contacts?")
       .setCancelable(false)
       .setPositiveButton(
           "Yes, import.",
           new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int id) {
               Toast toast =
                   Toast.makeText(
                       getApplicationContext(), "Imported all contacts.", Toast.LENGTH_SHORT);
               getAndroidContacts();
               onResume();
             }
           })
       .setNegativeButton(
           "No, don't import.",
           new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int id) {
               // if this button is clicked, just close
               // the dialog box and do nothing
             }
           });
   // create alert dialog
   AlertDialog alertDialog = alertDialogBuilder.create();
   // show it
   alertDialog.show();
 }
  private void handleStartSecureSession() {
    if (getRecipients() == null) {
      Toast.makeText(
              this, getString(R.string.ConversationActivity_invalid_recipient), Toast.LENGTH_LONG)
          .show();
      return;
    }

    final Recipient recipient = getRecipients().getPrimaryRecipient();
    String recipientName =
        (recipient.getName() == null ? recipient.getNumber() : recipient.getName());
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.ConversationActivity_initiate_secure_session_question);
    builder.setIcon(Dialogs.resolveIcon(this, R.attr.dialog_info_icon));
    builder.setCancelable(true);
    builder.setMessage(
        String.format(
            getString(R.string.ConversationActivity_initiate_secure_session_with_s_question),
            recipientName));
    builder.setPositiveButton(
        R.string.yes,
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            KeyExchangeInitiator.initiate(ConversationActivity.this, masterSecret, recipient, true);
          }
        });

    builder.setNegativeButton(R.string.no, null);
    builder.show();
  }
Example #19
0
 /** 弹出网络设置对话框 */
 public static void goSettingNetwork(final Context context) {
   AlertDialog.Builder aDialog = new AlertDialog.Builder(context);
   aDialog
       .setIcon(android.R.drawable.ic_dialog_info)
       .setTitle(R.string.prompt)
       .setMessage(R.string.network_not_connected)
       .setPositiveButton(
           R.string.cancle,
           new DialogInterface.OnClickListener() {
             @Override
             public void onClick(DialogInterface dialog, int which) {
               dialog.dismiss();
             }
           })
       .setNeutralButton(
           R.string.setting,
           new DialogInterface.OnClickListener() {
             @Override
             public void onClick(DialogInterface dialog, int which) {
               Intent netIntent = new Intent(Settings.ACTION_SETTINGS);
               context.startActivity(netIntent);
             }
           })
       .show();
 }
Example #20
0
 // 確認ダイアログ
 private void confirmDialog() {
   // ダイアログ生成
   AlertDialog.Builder dialog = new AlertDialog.Builder(this);
   dialog.setIcon(android.R.drawable.ic_menu_info_details);
   dialog.setTitle("確認ダイアログ");
   dialog.setMessage(confirmTxt());
   dialog.setPositiveButton(
       "OK",
       new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
           if ("1".equals(modeFlag)) {
             editModeDialog(); // 変更モード選択へ
           } else {
             dbMainHandling(); // データ操作へ
           }
         }
       });
   dialog.setNegativeButton(
       "キャンセル",
       new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
           showMsg("キャンセルが押されました。\n" + modeType + "処理を終了します。");
         }
       });
   dialog.show(); // ダイアログ表示
 }
  public void onLongItemSelected(int seleccion) {
    AlertDialog.Builder dialog = new AlertDialog.Builder(this);
    dialog.setTitle("Confirmar");
    dialog.setMessage("¿Seguro que quiere borrar la partida?");
    dialog.setIcon(android.R.drawable.ic_dialog_info);

    dialog.setCancelable(false);
    dialog.setPositiveButton(
        "Si",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
            // Hacer Algo;
            dialog.cancel();
          }
        });
    dialog.setNegativeButton(
        "No",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
            // Cancelar
            dialog.cancel();
          }
        });

    dialog.show();
  }
 public void show(IBinder ibinder) {
   Object obj = mMenu;
   android.app.AlertDialog.Builder builder =
       new android.app.AlertDialog.Builder(((MenuBuilder) (obj)).getContext());
   mPresenter =
       new ListMenuPresenter(
           android.support.v7.appcompat.R.layout.abc_list_menu_item_layout,
           android.support.v7.appcompat.R.style.Theme_AppCompat_CompactMenu_Dialog);
   mPresenter.setCallback(this);
   mMenu.addMenuPresenter(mPresenter);
   builder.setAdapter(mPresenter.getAdapter(), this);
   View view = ((MenuBuilder) (obj)).getHeaderView();
   if (view != null) {
     builder.setCustomTitle(view);
   } else {
     builder
         .setIcon(((MenuBuilder) (obj)).getHeaderIcon())
         .setTitle(((MenuBuilder) (obj)).getHeaderTitle());
   }
   builder.setOnKeyListener(this);
   mDialog = builder.create();
   mDialog.setOnDismissListener(this);
   obj = mDialog.getWindow().getAttributes();
   obj.type = 1003;
   if (ibinder != null) {
     obj.token = ibinder;
   }
   obj.flags = ((android.view.WindowManager.LayoutParams) (obj)).flags | 0x20000;
   mDialog.show();
 }
Example #23
0
  public void showAboutDialog() {

    final TextView message = new TextView(this);
    final SpannableString spannableString =
        new SpannableString(getString(R.string.dialog_about_body));
    Linkify.addLinks(spannableString, Linkify.ALL);
    message.setText(spannableString);
    message.setMovementMethod(LinkMovementMethod.getInstance());

    AlertDialog.Builder dialog = new AlertDialog.Builder(this);
    dialog.setIcon(R.drawable.about);
    dialog.setTitle(getString(R.string.dialog_about_title));
    dialog.setMessage(spannableString);
    // dialog.setView(message);
    dialog.setNeutralButton(
        getString(R.string.dialog_ack),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
          }
        });
    AlertDialog alertDialog = dialog.show();
    ((TextView) alertDialog.findViewById(android.R.id.message))
        .setMovementMethod(LinkMovementMethod.getInstance());
  }
Example #24
0
 // Al crear el diálogo. Retorna el diálogo configurado.
 @Override
 public Dialog onCreateDialog(Bundle savedInstanceState) {
   AlertDialog.Builder b = new AlertDialog.Builder(this.getActivity());
   b.setTitle(R.string.eliminar_usuario);
   b.setMessage(R.string.esta_seguro_de_que_quiere_eliminar_el_usuario);
   b.setIcon(R.drawable.ic_launcher);
   b.setPositiveButton(
       R.string.si,
       new OnClickListener() {
         // Al pulsar el botón positivo.
         @Override
         public void onClick(DialogInterface dialog, int which) {
           // Se notifica el evento al listener.
           mListener.onPositiveButtonClick(SiNoDialogFragment.this);
         }
       });
   b.setNegativeButton(
       R.string.no,
       new OnClickListener() {
         // Al pulsar el botón negativo.
         @Override
         public void onClick(DialogInterface dialog, int which) {
           // Se notifica el evento al listener.
           mListener.onNegativeButtonClick(SiNoDialogFragment.this);
         }
       });
   return b.create();
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   // évènement appelé lorsqu'un menu est choisi
   switch (item.getItemId()) {
       // l'identifiant integer est moins gourmand en ressource que le
       // string
     case 2001:
       Toast.makeText(this, "Paramètres", 1000).show();
       Intent intentParametres = new Intent(this, tab_param.class);
       intentParametres.putExtra(ActivityParam.LaunchFromRechercheProduitPerime, true);
       // on demarre la nouvelle activité
       startActivity(intentParametres);
       termineActivity();
       break;
     case 2002:
       Toast.makeText(this, "Notes", 1000).show();
       Intent intentNote = new Intent(this, note_page1.class);
       // on demarre la nouvelle activité
       startActivity(intentNote);
       termineActivity();
       break;
     case 2003:
       AlertDialog.Builder adHelp = new AlertDialog.Builder(this);
       adHelp.setTitle("Aide");
       adHelp.setIcon(R.drawable.ad_question);
       adHelp.setMessage(
           "En cliquant sur un produit vous pourrez afficher le détail de celui-ci ou le copier dans une nouvelle note.\n"
               + "En appuyant longtemps sur un produit, vous pourrez le supprimer.\n");
       adHelp.setPositiveButton("Ok", null);
       adHelp.show();
   }
   Log.i("", "" + item.getTitle());
   return super.onOptionsItemSelected(item);
 }
  /** Show a dialog for choosing the sort mode. Perform the change if required. */
  private void changeSortMode() {

    int currentSort =
        PreferenceManager.getDefaultSharedPreferences(this)
            .getInt(Constants.PREFERENCES_BOOKMARKS_SORT_MODE, 0);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setInverseBackgroundForced(true);
    builder.setIcon(android.R.drawable.ic_dialog_info);
    builder.setTitle(getResources().getString(R.string.BookmarksListActivity_MenuSortMode));
    builder.setSingleChoiceItems(
        new String[] {
          getResources().getString(R.string.BookmarksListActivity_AlphaSortMode),
          getResources().getString(R.string.BookmarksListActivity_RecentSortMode)
        },
        currentSort,
        new OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            doChangeSortMode(which);
            dialog.dismiss();
          }
        });
    builder.setCancelable(true);
    builder.setNegativeButton(R.string.Commons_Cancel, null);

    AlertDialog alert = builder.create();
    alert.show();
  }
  private void showDurationDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setIcon(R.drawable.ic_mms_duration);
    String title = getResources().getString(R.string.duration_selector_title);
    builder.setTitle(title + (mPosition + 1) + "/" + mSlideshowModel.size());

    builder.setItems(
        R.array.select_dialog_items,
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            if ((which >= 0) && (which < NUM_DIRECT_DURATIONS)) {
              mSlideshowEditor.changeDuration(mPosition, (which + 1) * 1000);
            } else {
              Intent intent = new Intent(SlideEditorActivity.this, EditSlideDurationActivity.class);
              intent.putExtra(EditSlideDurationActivity.SLIDE_INDEX, mPosition);
              intent.putExtra(EditSlideDurationActivity.SLIDE_TOTAL, mSlideshowModel.size());
              intent.putExtra(
                  EditSlideDurationActivity.SLIDE_DUR,
                  mSlideshowModel.get(mPosition).getDuration() / 1000); // in seconds
              startActivityForResult(intent, REQUEST_CODE_CHANGE_DURATION);
            }
            dialog.dismiss();
          }
        });

    builder.show();
  }
Example #28
0
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.shutdown_type_title);
    builder.setIcon(R.drawable.shutdown);
    builder.setItems(
        R.array.shutdown_options,
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {
            switch (which) {
              case 0:
                // reboot
                mShutdownDialogListener.onRebootClick(dialog);
                break;
              case 1:
                // halt
                mShutdownDialogListener.onHaltClick(dialog);
              default:
                break;
            }
          }
        });
    return builder.create();
  }
 private void ShowSaveConfirmDialog() {
   AlertDialog.Builder builder =
       new AlertDialog.Builder(this, android.R.layout.select_dialog_item);
   builder.setNegativeButton(
       getResources().getString(R.string.cancel),
       new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
           Toast.makeText(P005AlertDialogProf.this, "Negative", Toast.LENGTH_SHORT).show();
           textViewP005.setText(R.string.failed);
         }
       });
   builder.setPositiveButton(
       getResources().getString(R.string.save),
       new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
           Toast.makeText(P005AlertDialogProf.this, "Positive", Toast.LENGTH_SHORT).show();
           textViewP005.setText(R.string.successful);
         }
       });
   builder.setTitle("Are you sure?");
   builder.setIcon(R.drawable.fadein);
   builder.create();
   builder.show();
 }
Example #30
0
  private void welcome(final String strName) {

    AlertDialog.Builder objBuilder = new AlertDialog.Builder(this);
    objBuilder.setIcon(R.drawable.danger);
    objBuilder.setTitle("Welcome");
    objBuilder.setMessage("Welcome " + strName);
    objBuilder.setCancelable(false); // ถ้าต้องการปิด Popup จะกดไม่ได้ ต้องกด OK อย่างเดียว
    objBuilder.setPositiveButton(
        "OK",
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialogInterface, int i) {
            // ถ้ามีกา Click จะให้ทำอะไร

            // Intent to Order Activitites  เมื่อคลิกแล้วจะให้ไปี่หน้า Order Activitites
            Intent objIntent = new Intent(MainActivity.this, OrderActivity.class);
            objIntent.putExtra("Name", strName); // Name เป็น Key ที้่ใช้ในการโยน  Data ไปอีกหน้า
            startActivity(objIntent);

            dialogInterface.dismiss();
            finish(); // เมื่อกด Undo ที่โทรศัพท์ ให้ออกจาก App เลย ต้อง Login ใหม่
          }
        });
    objBuilder.show();
  } // welcome