List of usage examples for android.content DialogInterface cancel
void cancel();
From source file:com.sourcey.materiallogindemo.PostItemActivity.java
private void DialogMap() { View dialogBoxView = View.inflate(this, R.layout.activity_map, null); final WebView map = (WebView) dialogBoxView.findViewById(R.id.webView); String url = getString(R.string.url_map) + "index.php?poinFrom=" + strStart + "&poinTo=" + strEnd; map.getSettings().setLoadsImagesAutomatically(true); map.getSettings().setJavaScriptEnabled(true); map.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); map.loadUrl(url);//from ww w . j a v a 2 s . co m 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:app.socialgps.ui.MainActivity.java
private void selectItem(int position) { // update the main content by replacing fragments // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); setTitle(menuItems[position]);/*from w w w . j a v a 2 s. c o m*/ mDrawerLayout.closeDrawer(mDrawerList); // Fragment mapfragment = new MapsFragment(); // MapsFragment defined at top FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); switch (position) { case 0: // googleMap = (GoogleMap) mapFragment.getMap(); MapsFragment mf = new MapsFragment(); ft.replace(R.id.content_frame, mf).commit(); break; case 1: FriendListFragment flf = new FriendListFragment(); // Toast.makeText(getApplicationContext(), // "Yet to design Contacts view", Toast.LENGTH_LONG).show(); ft.replace(R.id.content_frame, flf).commit(); break; case 2: ContactListFragment clf = new ContactListFragment(); // Toast.makeText(getApplicationContext(), // "Yet to design Contacts view", Toast.LENGTH_LONG).show(); ft.replace(R.id.content_frame, clf).commit(); break; case 3: AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); alertDialog.setTitle("Logout"); alertDialog.setMessage("Are you sure you want Logout?"); alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { d = new DatabaseHandler(getApplicationContext()); Toast.makeText(getApplicationContext(), " logged out " + d.truncate(), Toast.LENGTH_SHORT) .show(); finish(); } }); // Showing Alert Message alertDialog.show(); break; // comment } }
From source file:bulat.diet.helper_couch.common.fragment.ExpandableItemPinnedMessageDialogFragment.java
@NonNull @Override/*from w w w .j a v a 2 s. com*/ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final int groupPosition = getArguments().getInt(KEY_GROUP_ITEM_POSITION, Integer.MIN_VALUE); final int childPosition = getArguments().getInt(KEY_CHILD_ITEM_POSITION, Integer.MIN_VALUE); // for expandable list if (childPosition == RecyclerView.NO_POSITION) { // builder.setMessage(getString(R.string.dialog_message_group_item_pinned, groupPosition)); } else { // builder.setMessage(getString(R.string.dialog_message_child_item_pinned, groupPosition, childPosition)); } 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:es.uniovi.imovil.fcrtrainer.BinaryExerciseFragment.java
private void dialogGameOver() { String message = getResources().getString(R.string.lost); if (this.won) { message = getResources().getString(R.string.won) + " " + getResources().getString(R.string.points) + " " + this.points; }//from w w w .j ava 2 s. c om Builder alert = new AlertDialog.Builder(getActivity()); alert.setTitle(getResources().getString(R.string.game_over)); alert.setMessage(message); alert.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); // nothing to do... } }); alert.show(); }
From source file:br.liveo.ndrawer.ui.fragment.MainFragment32.java
private void successDialog() { AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity()); alertDialog.setTitle(" ? "); alertDialog.setMessage("? ? ??"); alertDialog.setIcon(R.drawable.ic_dialog_alert); alertDialog.setPositiveButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); Fragment mFragment;//ww w . j av a2 s. c om FragmentManager mFragmentManager = getActivity().getSupportFragmentManager(); mFragment = new ViewPagerFragment3(); if (mFragment != null) { mFragmentManager.beginTransaction().replace(R.id.container, mFragment).commit(); } } }); alertDialog.show(); }
From source file:com.h6ah4i.android.example.advrecyclerview.common.fragment.ExpandableItemPinnedMessageDialogFragment.java
@NonNull @Override/*from ww w. j a v a 2 s . c o m*/ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final int groupPosition = getArguments().getInt(KEY_GROUP_ITEM_POSITION, Integer.MIN_VALUE); final int childPosition = getArguments().getInt(KEY_CHILD_ITEM_POSITION, Integer.MIN_VALUE); // for expandable list if (childPosition == RecyclerView.NO_POSITION) { builder.setMessage(getString(R.string.dialog_message_group_item_pinned, groupPosition)); } else { builder.setMessage(getString(R.string.dialog_message_child_item_pinned, groupPosition, childPosition)); } 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:br.com.GUI.perfil.HomePersonal.java
public boolean onOptionsItemSelected(MenuItem item) { // Take appropriate action for each action item click switch (item.getItemId()) { case R.id.actSolicitacoesDeAmizadePersonal: ArrayList<Aluno> solicitacoes = new Aluno().buscarAlunoNaoConfirmadoPorPersonalWeb("", pref.getString("usuario", null)); if (!solicitacoes.isEmpty()) { Intent i = new Intent(this, SolicitacoesDeAmizade.class); startActivity(i);//from w w w . ja v a2 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.actLogoutPersonal: finish(); Intent login = new Intent(this, Login.class); login.putExtra("logout", true); editor.clear(); editor.commit(); startActivity(login); return true; case R.id.actAdicionarAlunos: Intent adicionarAlunos = new Intent(this, BuscarUsuario.class); startActivity(adicionarAlunos); return true; case R.id.actAlterarDadosPessoaisPersonal: if (pref.getBoolean("isFacebookUser", false)) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(HomePersonal.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.actNovaAvaliacao: Intent avaliacoesIntent = new Intent(this, AvaliarGorduraCorporal.class); startActivity(avaliacoesIntent); return true; case R.id.actNovoTreinamento: AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); alertDialog.setTitle("Ops..."); alertDialog.setMessage("Digite um nome para o novo treinamento"); alertDialog.setIcon(R.drawable.critical); // Set an EditText view to get user input final EditText input = new EditText(this); alertDialog.setView(input); alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Treinamento t = new Treinamento(0, input.getText().toString(), null, null, pref.getString("usuario", null), null); //Log.i("interface: treinamento", t.toString()); try { int resultado = t.salvarTreinamentoWeb(b); if (resultado > 0) { Log.i("interface: salvei web", "salvei web"); t.setCodTreinamento(resultado); if (t.salvarTreinamento(b, pref.getString("usuario", null))) { Log.i("interface: salvei local", "salvei local"); Toast.makeText(HomePersonal.this, "Salvo com sucesso!", Toast.LENGTH_SHORT).show(); } } } catch (Exception ex) { ex.printStackTrace(); Toast.makeText(HomePersonal.this, "Erro ao salvar!", Toast.LENGTH_SHORT).show(); } } }); alertDialog.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); // Showing Alert Message alertDialog.show(); } return false; }
From source file:com.Candy.center.AboutCandy.java
private void dialog(boolean success) { final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); if (success == true) { alert.setMessage(R.string.report_infosuccess).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // action for ok dialog.cancel(); }//from w ww. j a va 2 s . c o m }); } else { alert.setMessage(R.string.report_infofail).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // action for ok dialog.cancel(); } }); } alert.show(); }
From source file:com.brewcrewfoo.performance.fragments.BatteryInfo.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.tablist: Helpers.getTabList(getString(R.string.menu_tab), (ViewPager) getView().getParent(), getActivity()); break;/*from w ww . j a v a 2s . c o m*/ case R.id.app_settings: Intent intent = new Intent(context, PCSettings.class); startActivity(intent); break; case R.id.calib: if (!new File(bstatfile).exists()) { Toast.makeText(context, getString(R.string.no_file, bstatfile), Toast.LENGTH_SHORT); break; } if ((level == 100) && (plugged != 0)) { //calibrate final LayoutInflater factory = LayoutInflater.from(context); final View cDialog = factory.inflate(R.layout.calib_dialog, null); final CheckBox sw = (CheckBox) cDialog.findViewById(R.id.sw); AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(getString(R.string.mt_calib)).setView(cDialog) .setMessage(getString(R.string.mt_calib_ok)) .setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).setPositiveButton(getString(R.string.mt_calib), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { StringBuilder sb = new StringBuilder(); sb.append("busybox rm -f " + bstatfile + ";\n"); if (sw.isChecked()) { mPreferences.edit().putBoolean("booting", true).commit(); sb.append("reboot;\n"); } Helpers.shExec(sb, context, true); dialog.cancel(); } }); AlertDialog alertDialog = builder.create(); alertDialog.show(); } else { new AlertDialog.Builder(context).setTitle(getString(R.string.mt_calib)) .setMessage(getString(R.string.mt_calib_nok)) .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).create().show(); } break; } return true; }
From source file:de.geeksfactory.opacclient.frontend.AccountEditActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { supportFinishAfterTransition();// w w w . j a va 2 s .c o m return true; } else if (item.getItemId() == R.id.action_accept) { saveAndCheck(); return true; } else if (item.getItemId() == R.id.action_cancel) { if (getIntent().hasExtra("adding") && getIntent().getBooleanExtra("adding", false)) { delete(); } supportFinishAfterTransition(); return true; } else if (item.getItemId() == R.id.action_delete) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.account_delete_confirm).setCancelable(true) .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface d, int id) { d.cancel(); } }).setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface d, int id) { d.dismiss(); delete(); finish(); } }).setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface d) { if (d != null) { d.cancel(); } } }); AlertDialog alert = builder.create(); alert.show(); return true; } return super.onOptionsItemSelected(item); }