List of usage examples for android.content DialogInterface cancel
void cancel();
From source file:br.com.GUI.perfil.HomeAluno.java
public boolean onOptionsItemSelected(MenuItem item) { // Take appropriate action for each action item click switch (item.getItemId()) { case R.id.actSolicitacoesDeAmizadeAluno: Personal solicitacoes = new Aluno() .buscarPersonalNaoConfirmadoPorAlunoWeb(pref.getString("usuario", null)); Log.i("usuario", solicitacoes.toString()); if (solicitacoes.getUsuario() != null) { Intent i = new Intent(this, SolicitacoesDeAmizade.class); startActivity(i);//from w w w . j av a 2 s .c o m } else { AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); alertDialog.setTitle("Ops..."); alertDialog.setMessage(R.string.label_voce_nao_possui_solicitacoes_de_amizade); alertDialog.setIcon(R.drawable.profile); alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); // Showing Alert Message alertDialog.show(); } return true; case R.id.actLogoutAluno: finish(); Intent login = new Intent(this, Login.class); login.putExtra("logout", true); editor.clear(); editor.commit(); startActivity(login); return true; case R.id.actAdicionarPersonal: Intent adicionarAlunos = new Intent(this, BuscarUsuario.class); startActivity(adicionarAlunos); return true; case R.id.actAlterarDadosPessoaisAluno: if (pref.getBoolean("isFacebookUser", false)) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(HomeAluno.this); alertDialog.setTitle("Erro"); alertDialog.setMessage( "Seu cadastro est vinculado ao Facebook, sendo assim, no possivel alterao de informaes pessoais"); alertDialog.setIcon(R.drawable.profile); alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); // Showing Alert Message alertDialog.show(); } else { Intent alterarDados = new Intent(this, AlterarDadosPessoais.class); startActivity(alterarDados); } return true; case R.id.actPerfil: Intent perfilIntent = new Intent(this, PerfilPersonal.class); startActivity(perfilIntent); return true; case R.id.actMarcarAula: Aluno a = new Aluno().buscarAlunoEspecifico(b, pref.getString("usuario", null)); if (a.getUsuarioPersonal() != null) { Intent marcarAulaIntent = new Intent(this, MarcarAula.class); startActivity(marcarAulaIntent); } else { AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); alertDialog.setTitle("Ops..."); alertDialog.setMessage("Antes de voc agendar uma aula necessrio que voc " + " possua um treinador para lhe auxiliar na sua rotina de exerccios"); alertDialog.setIcon(R.drawable.horarios); alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); // Showing Alert Message alertDialog.show(); } return true; case R.id.actNovaAvaliacao: Intent avaliacoesIntent = new Intent(this, AvaliarGorduraCorporal.class); startActivity(avaliacoesIntent); return true; } return false; }
From source file:org.xbmc.android.remote.presentation.controller.AbstractController.java
protected void showDialog(final AlertDialog.Builder builder) { builder.setCancelable(true);//from ww w .j a v a 2s .c o m builder.setNegativeButton("Close", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); mDialogShowing = false; // ConnectionManager.resetClient(); } }); mActivity.runOnUiThread(new Runnable() { public void run() { final AlertDialog alert = builder.create(); try { if (!mDialogShowing) { alert.show(); mDialogShowing = true; } } catch (Exception e) { e.printStackTrace(); } } }); }
From source file:com.breadwallet.BreadWalletApp.java
public void showCustomDialog(final String title, final String message, final String buttonText) { Activity app = MainActivity.app;/*from ww w . j a v a2 s . c om*/ if (app == null) app = IntroActivity.app; if (app == null) { Log.e(TAG, "showCustomDialog: FAILED, context is null"); return; } final Activity finalApp = app; app.runOnUiThread(new Runnable() { @Override public void run() { new android.app.AlertDialog.Builder(finalApp).setTitle(title).setMessage(message) .setPositiveButton(buttonText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }).setIcon(android.R.drawable.ic_dialog_alert).show(); } }); }
From source file:at.general.solutions.android.ical.activity.ICalSynchronizeActivity.java
protected Dialog createSettingsIncompleteDialog(final int dialogId) { AlertDialog.Builder dlgBuilder = new AlertDialog.Builder(this).setTitle(getString(R.string.anErrorOccured)) .setMessage(getString(R.string.preferencesIncomplete)).setCancelable(false) .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override/* w ww. j av a2 s .c om*/ public void onClick(DialogInterface dialog, int which) { dialog.cancel(); removeDialog(dialogId); } }); return dlgBuilder.create(); }
From source file:com.sourcey.materiallogindemo.NotificationActivity.java
private void DialogConfirmRequest() { View dialogBoxView = View.inflate(this, R.layout.dialog_confirm_request, null); final Button btnAccept = (Button) dialogBoxView.findViewById(R.id.btnAccept); final Button btnReject = (Button) dialogBoxView.findViewById(R.id.btnReject); btnAccept.setOnClickListener(new View.OnClickListener() { @Override//from www. j a v a 2 s . c om public void onClick(View v) { saveConfirm(request_id, "ACCEPT"); } }); btnReject.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { saveConfirm(request_id, "REJECT"); } }); /* String url = getString(R.string.url_map)+"index.php?poinFrom="+txtStart.getText().toString().trim()+"&poinTo="+txtEnd.getText().toString().trim(); map.getSettings().setLoadsImagesAutomatically(true); map.getSettings().setJavaScriptEnabled(true); map.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); map.loadUrl(url);*/ AlertDialog.Builder builderInOut = new AlertDialog.Builder(this); builderInOut.setTitle("?"); builderInOut.setMessage("").setView(dialogBoxView).setCancelable(false) .setPositiveButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).show(); }
From source file:bulat.diet.helper_couch.common.fragment.ItemPinnedMessageDialogFragment.java
@NonNull @Override/*from w w w . j av a2s. co m*/ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final int itemPosition = getArguments().getInt(KEY_ITEM_POSITION, Integer.MIN_VALUE); // builder.setMessage(getString(R.string.dialog_message_item_pinned, itemPosition)); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { notifyItemPinnedDialogDismissed(true); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.setCancelable(true); return builder.create(); }
From source file:com.example.chinyao.mow.mow.recycler.ItemPinnedMessageDialogFragment.java
@NonNull @Override//from w w w. j ava2 s .c om public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final int itemPosition = getArguments().getInt(KEY_ITEM_POSITION, Integer.MIN_VALUE); builder.setMessage(getString(R.string.dialog_message_item_pinned, itemPosition)); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { notifyItemPinnedDialogDismissed(true); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.setCancelable(true); return builder.create(); }
From source file:com.google.android.gcm.demo.ui.NetworkSchedulerFragment.java
private void showDialog(final int type) { AlertDialog.Builder alertBuilder = new AlertDialog.Builder(getActivity()); @SuppressLint("InflateParams") // the layout is used inside a dialog so no parent is needed LinearLayout layout = (LinearLayout) getActivity().getLayoutInflater() .inflate(R.layout.widget_schedule_task_dialog, null); if (type == TYPE_ONE_OFF) { alertBuilder.setTitle(R.string.scheduler_add_oneoff); alertBuilder.setMessage(R.string.scheduler_add_oneoff_message); alertBuilder.setPositiveButton(R.string.scheduler_add_oneoff, null); ((TextView) layout.findViewById(R.id.task_param1_title)).setText(R.string.scheduler_run_from); ((TextView) layout.findViewById(R.id.task_param2_title)).setText(R.string.scheduler_run_by); } else {/*from www . j a v a2 s.c o m*/ alertBuilder.setTitle(R.string.scheduler_add_periodic); alertBuilder.setMessage(R.string.scheduler_add_periodic_message); alertBuilder.setPositiveButton(R.string.scheduler_add_periodic, null); ((TextView) layout.findViewById(R.id.task_param1_title)).setText(R.string.scheduler_period); ((TextView) layout.findViewById(R.id.task_param2_title)).setText(R.string.scheduler_flex); } final EditText param1View = (EditText) layout.findViewById(R.id.task_param1); final EditText param2View = (EditText) layout.findViewById(R.id.task_param2); final RadioGroup connectivityView = (RadioGroup) layout.findViewById(R.id.task_connectivity_group); final CheckBox chargingView = (CheckBox) layout.findViewById(R.id.task_charging_checkbox); final CheckBox persistenceView = (CheckBox) layout.findViewById(R.id.task_persistence_checkbox); alertBuilder.setView(layout); alertBuilder.setNegativeButton(R.string.scheduler_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); // Show the dialog final AlertDialog dialog = alertBuilder.create(); dialog.show(); dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // schedule the task final long value1; final long value2; try { value1 = Long.parseLong(param1View.getText().toString()); value2 = Long.parseLong(param2View.getText().toString()); } catch (NumberFormatException e) { Toast.makeText(getActivity(), getString(R.string.scheduler_error_nan), Toast.LENGTH_SHORT) .show(); return; } int connectivity = Task.NETWORK_STATE_CONNECTED; switch (connectivityView.getCheckedRadioButtonId()) { case R.id.task_connectivity_connected: connectivity = Task.NETWORK_STATE_CONNECTED; break; case R.id.task_connectivity_unmetered: connectivity = Task.NETWORK_STATE_UNMETERED; break; case R.id.task_connectivity_any: connectivity = Task.NETWORK_STATE_ANY; break; } boolean charging = chargingView.isChecked(); boolean persistence = persistenceView.isChecked(); if (type == TYPE_ONE_OFF) { addOneOff(value1, value2, connectivity, charging); } else { addPeriodic(value1, value2, connectivity, charging, persistence); } refresh(); dialog.dismiss(); } }); }
From source file:br.liveo.ndrawer.ui.fragment.MainFragment32.java
private void failDialog() { AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity()); alertDialog.setTitle(" ? "); alertDialog.setMessage("? ?? "); alertDialog.setIcon(R.drawable.fail); alertDialog.setPositiveButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); }//from w w w .jav a2s.c o m }); alertDialog.show(); }
From source file:br.liveo.ndrawer.ui.fragment.MainFragment32.java
private void limitDialog() { AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity()); alertDialog.setTitle(" ? "); alertDialog.setMessage(" ? ? 6"); alertDialog.setIcon(R.drawable.fail); alertDialog.setPositiveButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); }//from w w w .j a v a 2s .c o m }); alertDialog.show(); }