List of usage examples for android.app AlertDialog.Builder show
public void show()
From source file:com.hackensack.umc.activity.DependentDetailsActivity.java
private void showDilaog(String message) { // DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { // @Override // public void onClick(DialogInterface dialog, int which) { // switch (which) { // case DialogInterface.BUTTON_POSITIVE: // new SubmitInfoCall().execute(); // dialog.dismiss(); // break; //// w w w .j a v a 2 s . com // case DialogInterface.BUTTON_NEGATIVE: // dialog.dismiss(); // break; // } // } // }; // // android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(DependentDetailsActivity.this); // builder.setTitle("Alert"); // builder.setMessage(message + " .Try again.").setPositiveButton("Yes", dialogClickListener).setNegativeButton("No", dialogClickListener).show(); if (!isFinishing()) { AlertDialog.Builder builder = new AlertDialog.Builder((getSupportActionBar().getThemedContext())); LayoutInflater inflater = getLayoutInflater(); View dialogView = inflater.inflate(R.layout.dialog_network_offline, null); builder.setView(dialogView); ((TextView) dialogView.findViewById(R.id.dialog_title)).setText("Alert"); ((TextView) dialogView.findViewById(R.id.text_message)).setText(message); Button btnCancel = (Button) dialogView.findViewById(R.id.button_dialog_cancel); btnCancel.setVisibility(View.VISIBLE); btnCancel.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { alert.dismiss(); } }); Button btnOk = (Button) dialogView.findViewById(R.id.button_dialog_ok); btnOk.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { new SubmitInfoCall().execute(); alert.dismiss(); } }); alert = builder.show(); } }
From source file:com.hackensack.umc.activity.DependentDetailsActivity.java
private void showGenderDialog() { if (!isFinishing()) { AlertDialog.Builder builder = new AlertDialog.Builder(DependentDetailsActivity.this); LayoutInflater inflater = this.getLayoutInflater(); View dialogView = inflater.inflate(R.layout.dialog_custom_list, null); builder.setView(dialogView);//from w w w .ja va2 s.c om ((TextView) dialogView.findViewById(R.id.dialog_title)).setText("Gender"); dialogView.findViewById(R.id.progress_bar).setVisibility(View.GONE); ((RelativeLayout) dialogView.findViewById(R.id.relative_dialog_button)).setVisibility(View.GONE); mDialogListView = (ListView) dialogView.findViewById(R.id.list_specialty); mDialogListView.setAdapter(mGenderAdapter); ((ListView) dialogView.findViewById(R.id.list_specialty)) .setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { mGender.setText(mGenderArray[i]); alert.dismiss(); mDialogListView = null; } }); alert = builder.show(); } }
From source file:com.devwang.logcabin.LogCabinMainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { Intent serverIntent = null;//ww w. j a v a2s .c o m Toast toast = Toast.makeText(LogCabinMainActivity.this, "", Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, 0, 0); switch (item.getItemId()) { case R.id.secure_connect_scan:// // Launch the DeviceListActivity to see devices and do scan serverIntent = new Intent(this, DeviceListActivity.class); startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE_SECURE); return true; case R.id.insecure_connect_scan:// // Launch the DeviceListActivity to see devices and do scan serverIntent = new Intent(this, DeviceListActivity.class); startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE_INSECURE); return true; case R.id.app_developer: toastDisplay(LogCabinMainActivity.this, ": \n\nQQ:1120341494\n:dongleixiaxue314\n :http://www.devwang.com", Gravity.CENTER, R.drawable.hutview, Toast.LENGTH_SHORT); return true; case R.id.app_cmd_what: case R.id.app_voice_what: toast.setText( "\n\n\n\n..."); toast.show(); return true; case R.id.app_college: toast.setText(R.string.str_college); toast.show(); return true; case R.id.app_web_url: toastDisplay(LogCabinMainActivity.this, getString(R.string.http_devwang_sinaapp_com_logcabin_logcabin_web_php), Gravity.CENTER, 0, Toast.LENGTH_SHORT); return true; case R.id.app_update: android.app.AlertDialog.Builder dialog = new AlertDialog.Builder(LogCabinMainActivity.this); LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.dialogview_appupdate, null); dialog.setView(layout); appUpdateEditText = (EditText) layout.findViewById(R.id.et_appupdate); dialog.setPositiveButton(R.string.str_app_update_sure, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String appUpdateEditTextString = appUpdateEditText.getText().toString(); if ("devwang".equals(appUpdateEditTextString.toString())) { AppUpdate = true; Toast.makeText(getApplicationContext(), R.string.str_app_update_pass_toast, Toast.LENGTH_SHORT).show(); } } }); dialog.show(); return true; } return false; }
From source file:adventure_fragments.Swimming.java
public void AddItemNow() { final EditText input; AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Add item to list"); input = new EditText(getActivity()); int maxLength = 20; input.setFilters(new InputFilter[] { new InputFilter.LengthFilter(maxLength) }); builder.setView(input);/*from ww w . j av a 2 s .com*/ builder.setPositiveButton("Add item", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String item_name = input.getText().toString(); if (item_name.equals("")) { Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show(); } else if (item_name.equals(" ")) { Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show(); } else if (item_name.equals(" ")) { Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show(); } else if (item_name.equals("This app sucks")) { Toast.makeText(getActivity(), "No it doesn't!", Toast.LENGTH_SHORT).show(); } else { ItemClass itemClass = new ItemClass(item_name, 0); db.addItemSwimming(itemClass); adapt.add(itemClass); adapt.notifyDataSetChanged(); list = db.getAllItemsSwimming(); adapt = new CustomAdapter6(getActivity(), R.layout.item_layout, list); listItem = (ListView) getActivity().findViewById(R.id.listview_swim); listItem.setAdapter(adapt); nothingtext = (TextView) rootView.findViewById(R.id.nothing_here_swim); count = listItem.getCount(); if (count > 0) { nothingtext.setVisibility(View.GONE); } else if (count == 0) { nothingtext.setVisibility(View.VISIBLE); } } } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.show(); }
From source file:adventure_fragments.Biking.java
public void AddItemNow() { final EditText input; AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Add item to list"); input = new EditText(getActivity()); int maxLength = 20; input.setFilters(new InputFilter[] { new InputFilter.LengthFilter(maxLength) }); builder.setView(input);/*from ww w. jav a 2s . c o m*/ builder.setPositiveButton("Add item", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String item_name = input.getText().toString(); if (item_name.equals("")) { Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show(); } else if (item_name.equals(" ")) { Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show(); } else if (item_name.equals(" ")) { Toast.makeText(getActivity(), "Please enter a name for the item", Toast.LENGTH_SHORT).show(); } else if (item_name.equals("This app sucks")) { Toast.makeText(getActivity(), "No it doesn't!", Toast.LENGTH_SHORT).show(); } else { ItemClass itemClass = new ItemClass(item_name, 0); db.addItemBiking(itemClass); adapt.add(itemClass); adapt.notifyDataSetChanged(); list = db.getAllItemsBiking(); adapt = new CustomAdapter(getActivity(), R.layout.item_layout, list); listItem = (ListView) getActivity().findViewById(R.id.listview_bike); listItem.setAdapter(adapt); nothingtext = (TextView) rootView.findViewById(R.id.nothing_here_bike); count = listItem.getCount(); if (count > 0) { nothingtext.setVisibility(View.GONE); } else if (count == 0) { nothingtext.setVisibility(View.VISIBLE); } } } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.show(); }
From source file:com.t2.compassionMeditation.Graphs1Activity.java
public void onButtonClick(View v) { final int id = v.getId(); switch (id) { // case R.id.buttonBack: // finish(); // // break; // case R.id.buttonAddMeasure: boolean toggleArray[] = new boolean[mBioParameters.size()]; for (int j = 0; j < mBioParameters.size(); ++j) { GraphBioParameter item = mBioParameters.get(j); if (item.visible) toggleArray[j] = true;//w ww . j av a2 s . co m else toggleArray[j] = false; } String[] measureNames = new String[mBioParameters.size()]; int i = 0; for (GraphBioParameter item : mBioParameters) { measureNames[i++] = item.title1; } // Present dialog to allow user to choose which parameters to view in this activity AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(R.string.alert_dialog_measure_selector); // alert.setMultiChoiceItems(R.array.measure_select_dialog_items, alert.setMultiChoiceItems(measureNames, toggleArray, new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) { GraphBioParameter item = mBioParameters.get(whichButton); item.visible = item.visible ? false : true; saveVisibleKeyIds(); generateChart(); } }); alert.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { generateChart(); } }); alert.show(); break; case R.id.buttonPause: if (mPaused == true) { mPaused = false; mPauseButton.getBackground().setColorFilter(Color.LTGRAY, PorterDuff.Mode.MULTIPLY); mPauseButton.setText(R.string.button_running); if (mLoggingEnabled) { try { mDataOutHandler.logNote(getString(R.string.un_paused)); } catch (DataOutHandlerException e) { Log.e(TAG, e.toString()); e.printStackTrace(); } // data header } if (mLogCatEnabled) { Log.d(TAG, "Un-Paused"); } } else { mPaused = true; mPauseButton.getBackground().setColorFilter(0xFFFF0000, PorterDuff.Mode.MULTIPLY); mPauseButton.setText(R.string.button_pause); if (mLoggingEnabled) { try { mDataOutHandler.logNote(getString(R.string.paused)); } catch (DataOutHandlerException e) { Log.e(TAG, e.toString()); e.printStackTrace(); } // data header } if (mLogCatEnabled) { Log.d(TAG, "Paused"); } } break; } // End switch }
From source file:au.com.wallaceit.reddinator.SubredditSelectActivity.java
private void showSortDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(SubredditSelectActivity.this); builder.setTitle("Pick a sort, any sort"); builder.setItems(R.array.reddit_sorts, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Editor prefsedit = mSharedPreferences.edit(); String sort = "hot"; // default if fails // find index switch (which) { case 0: sort = "hot"; break; case 1: sort = "new"; break; case 2: sort = "rising"; break; case 3: sort = "controversial"; break; case 4: sort = "top"; break; }//from www .j a va 2 s. c o m prefsedit.putString("sort-" + (mAppWidgetId == 0 ? "app" : mAppWidgetId), sort); prefsedit.apply(); // set new text in button String sorttxt = "Sort: " + sort; sortBtn.setText(sorttxt); needsFeedUpdate = true; // mark feed for updating dialog.dismiss(); } }); builder.show(); }
From source file:com.hackensack.umc.activity.RegistrationDetailsActivity.java
private void showDilaog(String message) { // DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { // @Override // public void onClick(DialogInterface dialog, int which) { // switch (which) { // case DialogInterface.BUTTON_POSITIVE: // new SubmitInfoCall().execute(); // dialog.dismiss(); // break; //// w w w. j a va 2 s .c om // case DialogInterface.BUTTON_NEGATIVE: // dialog.dismiss(); // break; // } // } // }; // // android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(RegistrationDetailsActivity.this); // builder.setTitle("Alert"); // builder.setMessage(message + " .Try again.").setPositiveButton("Yes", dialogClickListener).setNegativeButton("No", dialogClickListener).show(); if (!isFinishing()) { AlertDialog.Builder builder = new AlertDialog.Builder((getSupportActionBar().getThemedContext())); LayoutInflater inflater = getLayoutInflater(); View dialogView = inflater.inflate(R.layout.dialog_network_offline, null); builder.setView(dialogView); ((TextView) dialogView.findViewById(R.id.dialog_title)).setText("Alert"); ((TextView) dialogView.findViewById(R.id.text_message)).setText(message); Button btnCancel = (Button) dialogView.findViewById(R.id.button_dialog_cancel); btnCancel.setVisibility(View.VISIBLE); btnCancel.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { alert.dismiss(); } }); Button btnOk = (Button) dialogView.findViewById(R.id.button_dialog_ok); btnOk.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { new SubmitInfoCall().execute(); alert.dismiss(); } }); alert = builder.show(); } }
From source file:ee.ria.DigiDoc.fragment.ContainerDetailsFragment.java
private void startMobileSign() { View view = LayoutInflater.from(getActivity()).inflate(R.layout.mobile_id_dialogue, null); final EditText mobileNr = findById(view, R.id.mobile_nr); final EditText personalCode = findById(view, R.id.personal_code); final CheckBox rememberMe = findById(view, R.id.remember_me); final AppPreferences preferences = AppPreferences.get(getContext()); mobileNr.setText(preferences.getMobileNumber()); personalCode.setText(preferences.getPersonalCode()); final AlertDialog.Builder builder = new AlertDialog.Builder(getContext()) .setPositiveButton(R.string.sign_button, new DialogInterface.OnClickListener() { @Override/*from w w w . j a v a2s . c o m*/ public void onClick(DialogInterface dialog, int which) { refreshContainerFacade(); String phone = mobileNr.getText().toString(); String pCode = personalCode.getText().toString(); if (rememberMe.isChecked()) { preferences.updateMobileNumber(phone); preferences.updatePersonalCode(pCode); } String message = getResources().getString(R.string.action_sign) + " " + containerFacade.getName(); MobileCreateSignatureRequest request = CreateSignatureRequestBuilder .aCreateSignatureRequest().withContainer(containerFacade).withIdCode(pCode) .withPhoneNr(phone).withDesiredMessageToDisplay(message) .withLocale(Locale.getDefault()) .withLocalSigningProfile(getFutureSignatureProfile()).build(); Intent mobileSignIntent = new Intent(getActivity(), MobileSignService.class); mobileSignIntent.putExtra(CREATE_SIGNATURE_REQUEST, toJson(request)); mobileSignIntent.putExtra(ACCESS_TOKEN_PASS, Conf.instance().PKCS12Pass()); mobileSignIntent.putExtra(ACCESS_TOKEN_PATH, new File(FileUtils.getSchemaCacheDirectory(getContext()), "878252.p12") .getAbsolutePath()); getActivity().startService(mobileSignIntent); disableSigning(); } }).setNegativeButton(R.string.cancel, null).setView(view); notificationUtil.clearMessages(); builder.show(); }
From source file:com.hackensack.umc.activity.RegistrationDetailsActivity.java
private void showGenderDialog() { if (!isFinishing()) { AlertDialog.Builder builder = new AlertDialog.Builder(RegistrationDetailsActivity.this); LayoutInflater inflater = this.getLayoutInflater(); View dialogView = inflater.inflate(R.layout.dialog_custom_list, null); builder.setView(dialogView);/*from w ww . j av a 2 s .c om*/ ((TextView) dialogView.findViewById(R.id.dialog_title)).setText("Gender"); dialogView.findViewById(R.id.progress_bar).setVisibility(View.GONE); ((RelativeLayout) dialogView.findViewById(R.id.relative_dialog_button)).setVisibility(View.GONE); mDialogListView = (ListView) dialogView.findViewById(R.id.list_specialty); mDialogListView.setAdapter(mGenderAdapter); ((ListView) dialogView.findViewById(R.id.list_specialty)) .setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { mGender.setText(mGenderArray[i]); alert.dismiss(); mDialogListView = null; } }); alert = builder.show(); } }