List of usage examples for android.app AlertDialog dismiss
@Override public void dismiss()
From source file:com.ushahidi.android.app.ui.phone.AddCheckinActivity.java
/** * Create various dialog/*from w w w .j av a2 s . c o m*/ */ @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ERROR_NETWORK: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.network_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_ERROR_SAVING: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.file_system_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_CHOOSE_IMAGE_METHOD: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.choose_method)); dialog.setMessage(getString(R.string.how_to_select_pic)); dialog.setButton(getString(R.string.gallery_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, REQUEST_CODE_IMAGE); dialog.dismiss(); } }); dialog.setButton2(getString(R.string.cancel), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton3(getString(R.string.camera_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, PhotoUtils.getPhotoUri(photoName, AddCheckinActivity.this)); startActivityForResult(intent, REQUEST_CODE_CAMERA); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_SHOW_MESSAGE: AlertDialog.Builder messageBuilder = new AlertDialog.Builder(this); messageBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showDialog = messageBuilder.create(); showDialog.show(); break; case DIALOG_SHOW_REQUIRED: AlertDialog.Builder requiredBuilder = new AlertDialog.Builder(this); requiredBuilder.setTitle(R.string.required_fields); requiredBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showRequiredDialog = requiredBuilder.create(); showRequiredDialog.show(); break; // prompt for unsaved changes case DIALOG_SHOW_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.unsaved_changes)); dialog.setMessage(getString(R.string.want_to_cancel)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } // prompt for report deletion case DIALOG_SHOW_DELETE_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.delete_report)); dialog.setMessage(getString(R.string.want_to_delete)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // delete checkin deleteCheckins(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } } return null; }
From source file:dk.kk.ibikecphlib.map.MapActivity.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { Log.d(TAG, "onActivityResult, requestCode " + requestCode + " resultCode " + resultCode); if (requestCode == LeftMenu.LAUNCH_LOGIN) { Log.d(TAG, "Got back from the user login"); /*// w w w . j a v a 2s. c o m Log.d("JC", "Got back from LAUNCH_LOGIN"); if (!OverviewMapHandler.isWatchingAddress) { this.mapView.changeState(IBCMapView.MapViewState.DEFAULT); } leftMenu.populateMenu(); */ } else if (resultCode == ProfileActivity.RESULT_USER_DELETED) { Log.d(TAG, "Got back from deleting the user"); AlertDialog dialog; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(IBikeApplication.getString("account_deleted")); builder.setPositiveButton(IBikeApplication.getString("close"), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); dialog = builder.create(); dialog.show(); } else if (requestCode == REQUEST_SEARCH_ADDRESS && resultCode == RESULT_OK) { Log.d(TAG, "Got back from address search, with an OK result"); // Change state right away DestinationPreviewState state = this.changeState(DestinationPreviewState.class); // What address was selected? final Bundle extras = data.getExtras(); Address address = (Address) extras.getSerializable("addressObject"); if (address != null) { if (address.getSource() == Address.Source.FAVORITE) { address.setHouseNumber(""); } state.setDestination(address); } else { throw new RuntimeException("Expected an address"); } } else if (requestCode == REQUEST_SEARCH_ADDRESS && resultCode == RESULT_CANCELED) { Log.d(TAG, "Got back from address search were the user canceled!"); // throw new UnsupportedOperationException("Canceling the search address has not been implemented."); } else if (requestCode == REQUEST_CHANGE_SOURCE_ADDRESS && resultCode == SearchAutocompleteActivity.RESULT_AUTOTOCMPLETE_SET) { Log.d(TAG, "Got back from setting the source"); if (state instanceof RouteSelectionState) { final Bundle extras = data.getExtras(); Address address = (Address) extras.getSerializable("addressObject"); if (address != null) { ((RouteSelectionState) state).setSource(address); } else { throw new RuntimeException("Expected an address"); } } } else if (requestCode == REQUEST_CHANGE_DESTINATION_ADDRESS && resultCode == SearchAutocompleteActivity.RESULT_AUTOTOCMPLETE_SET) { Log.d(TAG, "Got back from setting the destination"); if (state instanceof RouteSelectionState) { final Bundle extras = data.getExtras(); Address address = (Address) extras.getSerializable("addressObject"); if (address != null) { ((RouteSelectionState) state).setDestination(address); } else { throw new RuntimeException("Expected an address"); } } } else if (requestCode == LeftMenu.LAUNCH_FAVORITE) { Log.d(TAG, "Got back from the favorite screen."); // We got a favorite to navigate to if (resultCode == RESULT_OK) { // TODO: Re-implement launching of favorites // throw new UnsupportedOperationException("Launching favorites not yet implemented using MapStates"); FavoriteListItem fd = data.getExtras().getParcelable("ROUTE_TO"); Address address = fd.getAddress(); RouteSelectionState state = changeState(RouteSelectionState.class); state.setDestination(address); // mapView.showRoute(fd); //mapView.showAddressFromFavorite(a); // Close the LeftMenu drawerLayout.closeDrawer(Gravity.LEFT); } } else if (requestCode == LeftMenu.LAUNCH_TRACKING) { Log.d(TAG, "Got back from the tracking screen."); } else if (requestCode == LeftMenu.LAUNCH_ABOUT) { Log.d(TAG, "Got back from the about screen."); } }
From source file:com.eleybourn.bookcatalogue.dialogs.StandardDialogs.java
/** * Select a custom item from a list, and call halder when/if item is selected. *//* ww w . j a v a2s .c om*/ public static void selectItemDialog(LayoutInflater inflater, String message, ArrayList<SimpleDialogItem> items, SimpleDialogItem selectedItem, final SimpleDialogOnClickListener handler) { // Get the view and the radio group final View root = inflater.inflate(R.layout.select_list_dialog, null); TextView msg = (TextView) root.findViewById(R.id.message); // Build the base dialog final AlertDialog.Builder builder = new AlertDialog.Builder(inflater.getContext()).setView(root); if (message != null && !message.equals("")) { msg.setText(message); } else { msg.setVisibility(View.GONE); } final AlertDialog dialog = builder.create(); // Create the listener for each item OnClickListener listener = new OnClickListener() { @Override public void onClick(View v) { SimpleDialogItem item = (SimpleDialogItem) ViewTagger.getTag(v, R.id.TAG_DIALOG_ITEM); // For a consistent UI, make sure the selector is checked as well. NOT mandatory from // a functional point of view, just consistent if (!(v instanceof RadioButton)) { RadioButton btn = item.getSelector(v); if (btn != null) { btn.setChecked(true); btn.invalidate(); } } // // It would be nice to have the other radio buttons reflect the new state before it // disappears, but not really worth the effort. Esp. since the code below does not work... // and the dialog disappears too fast to make this worthwhile. // //LinearLayout list = (LinearLayout)root.findViewById(R.id.list); //for(int i = 0; i < list.getChildCount(); i++) { // View child = list.getChildAt(i); // SimpleDialogItem other = (SimpleDialogItem)ViewTagger.getTag(child, R.id.TAG_DIALOG_ITEM); // RadioButton btn = other.getSelector(child); // btn.setSelected(other == item); // btn.invalidate(); //} dialog.dismiss(); handler.onClick(item); } }; // Add the items to the dialog LinearLayout list = (LinearLayout) root.findViewById(R.id.list); for (SimpleDialogItem item : items) { View v = item.getView(inflater); v.setBackgroundResource(android.R.drawable.list_selector_background); ViewTagger.setTag(v, R.id.TAG_DIALOG_ITEM, item); list.addView(v); v.setOnClickListener(listener); RadioButton btn = item.getSelector(v); if (btn != null) { ViewTagger.setTag(btn, R.id.TAG_DIALOG_ITEM, item); btn.setChecked(item == selectedItem); btn.setOnClickListener(listener); } } dialog.show(); }
From source file:org.mythdroid.activities.Main.java
private Dialog createWakeDialog() { final AlertDialog d = new AlertDialog.Builder(ctx).setItems(new String[] {}, null) .setIcon(drawable.ic_lock_power_off).setTitle(R.string.wakeFe).create(); d.getListView().setOnItemClickListener(new OnItemClickListener() { @Override//from w w w . j a v a 2 s . c o m public void onItemClick(AdapterView<?> av, View v, int pos, long id) { String name = (String) av.getAdapter().getItem(pos); try { WakeOnLan.wake(DatabaseUtil.getFrontendHwAddr(ctx, name)); Globals.curFe = name; } catch (Exception e) { ErrUtil.err(ctx, e); } d.dismiss(); } }); return d; }
From source file:emu.project64.GalleryActivity.java
public void ShowSupportWindow() { final Context context = this; final Activity activity = this; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getText(R.string.GetSaveSupport_title)); builder.setMessage(getText(R.string.GetSaveSupport_message)); builder.setNeutralButton("Not now", null); builder.setNegativeButton("Support Project64", null); builder.setCancelable(false);/*from www . jav a 2 s . c o m*/ final AlertDialog dialog = builder.create(); dialog.show(); dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); StartGameMenu(false); } }); dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setWaitScreen(true); //Purchase save support try { String payload = NativeExports.appVersion(); mIabHelper.launchPurchaseFlow(activity, SKU_SAVESUPPORT, RC_REQUEST, mPurchaseFinishedListener, payload); } catch (IabAsyncInProgressException e) { setWaitScreen(false); } dialog.dismiss(); } }); dialog.setCanceledOnTouchOutside(false); }
From source file:foam.littlej.android.app.ui.phone.AddCheckinActivity.java
/** * Create various dialog//from ww w. j a va 2 s. c o m */ @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ERROR_NETWORK: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.network_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_ERROR_SAVING: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.file_system_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_CHOOSE_IMAGE_METHOD: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.choose_method)); dialog.setMessage(getString(R.string.how_to_select_pic)); dialog.setButton(getString(R.string.gallery_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { deleteExistingPhoto(); Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, REQUEST_CODE_IMAGE); dialog.dismiss(); } }); dialog.setButton2(getString(R.string.cancel), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton3(getString(R.string.camera_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { deleteExistingPhoto(); Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, PhotoUtils.getPhotoUri(photoName, AddCheckinActivity.this)); startActivityForResult(intent, REQUEST_CODE_CAMERA); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_SHOW_MESSAGE: AlertDialog.Builder messageBuilder = new AlertDialog.Builder(this); messageBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showDialog = messageBuilder.create(); showDialog.show(); break; case DIALOG_SHOW_REQUIRED: AlertDialog.Builder requiredBuilder = new AlertDialog.Builder(this); requiredBuilder.setTitle(R.string.required_fields); requiredBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showRequiredDialog = requiredBuilder.create(); showRequiredDialog.show(); break; // prompt for unsaved changes case DIALOG_SHOW_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.unsaved_changes)); dialog.setMessage(getString(R.string.want_to_cancel)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // delete any existing photo in the pending folder new DiscardTask(AddCheckinActivity.this).execute((String) null); finish(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } // prompt for report deletion case DIALOG_SHOW_DELETE_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.delete_report)); dialog.setMessage(getString(R.string.want_to_delete)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // delete checkin deleteCheckins(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } } return null; }
From source file:com.gimranov.zandy.app.ItemActivity.java
protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_NEW: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getResources().getString(R.string.item_type)) // XXX i18n .setItems(Item.ITEM_TYPES_EN, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int pos) { Item item = new Item(getBaseContext(), Item.ITEM_TYPES[pos]); item.dirty = APIRequest.API_DIRTY; item.save(db);/*from ww w . ja v a 2 s. c o m*/ if (collectionKey != null) { ItemCollection coll = ItemCollection.load(collectionKey, db); if (coll != null) { coll.loadChildren(db); coll.add(item); coll.saveChildren(db); } } Log.d(TAG, "Loading item data with key: " + item.getKey()); // We create and issue a specified intent with the necessary data Intent i = new Intent(getBaseContext(), ItemDataActivity.class); i.putExtra("com.gimranov.zandy.app.itemKey", item.getKey()); startActivity(i); } }); AlertDialog dialog = builder.create(); return dialog; case DIALOG_SORT: // We generate the sort name list for our current locale String[] sorts = new String[SORT_NAMES.length]; for (int j = 0; j < SORT_NAMES.length; j++) { sorts[j] = getResources().getString(SORT_NAMES[j]); } AlertDialog.Builder builder2 = new AlertDialog.Builder(this); builder2.setTitle(getResources().getString(R.string.set_sort_order)).setItems(sorts, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int pos) { Cursor cursor; setSortBy(SORTS[pos]); ItemCollection collection; if (collectionKey != null && (collection = ItemCollection.load(collectionKey, db)) != null) { cursor = getCursor(collection); } else { if (query != null) { cursor = getCursor(query); } else { cursor = getCursor(); } } ItemAdapter adapter = (ItemAdapter) getListAdapter(); adapter.changeCursor(cursor); Log.d(TAG, "Re-sorting by: " + SORTS[pos]); Persistence.write(SORT_CHOICE, SORTS[pos]); } }); AlertDialog dialog2 = builder2.create(); return dialog2; case DIALOG_PROGRESS: mProgressDialog = new ProgressDialog(this); mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); mProgressDialog.setIndeterminate(true); mProgressDialog.setMessage(getResources().getString(R.string.identifier_looking_up)); return mProgressDialog; case DIALOG_IDENTIFIER: final EditText input = new EditText(this); input.setHint(getResources().getString(R.string.identifier_hint)); final ItemActivity current = this; dialog = new AlertDialog.Builder(this).setTitle(getResources().getString(R.string.identifier_message)) .setView(input).setPositiveButton(getResources().getString(R.string.menu_search), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Editable value = input.getText(); // run search Bundle c = new Bundle(); c.putString("mode", "isbn"); c.putString("identifier", value.toString()); removeDialog(DIALOG_PROGRESS); ItemActivity.this.b = c; showDialog(DIALOG_PROGRESS); } }) .setNeutralButton(getResources().getString(R.string.scan), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // If we're about to download from Google play, cancel that dialog // and prompt from Amazon if we're on an Amazon device IntentIntegrator integrator = new IntentIntegrator(current); @Nullable AlertDialog producedDialog = integrator.initiateScan(); if (producedDialog != null && "amazon".equals(BuildConfig.FLAVOR)) { producedDialog.dismiss(); AmazonZxingGlue.showDownloadDialog(current); } } }) .setNegativeButton(getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // do nothing } }) .create(); return dialog; default: return null; } }
From source file:org.inaturalist.android.GuideDetails.java
private void showEditDownloadDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); // Set the adapter String[] items = { getResources().getString(R.string.delete_download), getResources().getString(R.string.re_download), getResources().getString(R.string.cancel) }; builder.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items), null); final AlertDialog alertDialog = builder.create(); ListView listView = alertDialog.getListView(); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override/*from w w w . j a v a2s. c o m*/ public void onItemClick(AdapterView<?> parent, View view, int position, long id) { alertDialog.dismiss(); if (position == 0) { // Delete download mGuideXml.deleteOfflineGuide(); refreshGuideSideMenu(); } else if (position == 1) { // Re-download mGuideXml.deleteOfflineGuide(); downloadGuide(); } else { // Cancel } } }); alertDialog.show(); }
From source file:abanoubm.dayra.main.Main.java
private void sign() { String inpath;//w w w .ja v a 2 s . c o m if (android.os.Build.VERSION.SDK_INT >= 17) { inpath = getApplicationContext().getApplicationInfo().dataDir + "/databases/"; } else { inpath = "/data/data/" + getApplicationContext().getPackageName() + "/databases/"; } File folder = new File(inpath); File[] listOfFiles = folder.listFiles(); if (listOfFiles == null || listOfFiles.length == 0) { Toast.makeText(getApplicationContext(), R.string.msg_no_dayra, Toast.LENGTH_SHORT).show(); } else { ArrayList<String> names = new ArrayList<>(listOfFiles.length); for (File file : listOfFiles) { if (!file.getName().contains("journal")) names.add(file.getName()); } LayoutInflater li = LayoutInflater.from(getApplicationContext()); View signView = li.inflate(R.layout.dialogue_signin, null, false); final AlertDialog ad = new AlertDialog.Builder(Main.this).setCancelable(true).create(); ad.setView(signView, 0, 0, 0, 0); ad.show(); ListView nameslv = (ListView) signView.findViewById(R.id.databases_lv); nameslv.setAdapter(new ArrayAdapter<>(getApplicationContext(), R.layout.item_string, R.id.item, names)); nameslv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String str = (String) parent.getItemAtPosition(position); new SignTask().execute(str); ad.dismiss(); } }); } }
From source file:com.tnc.android.graphite.activities.GraphActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // TODO move to controller switch (item.getItemId()) { case R.id.graph_menu_reload: controller.handleMessage(GraphController.MESSAGE_RELOAD); break;/* w w w. j a v a2 s . c o m*/ case R.id.graph_menu_auto_refresh: controller.handleMessage(GraphController.MESSAGE_AUTO_REFRESH_DIALOG); break; case R.id.graph_menu_edit: layout.closeDrawers(); Intent editIntent = new Intent(this, EditActivity.class); startActivityForResult(editIntent, GraphController.ACTIVITY_EDIT_GRAPHS); break; case R.id.graph_menu_save: final EditText input = new EditText(this); final AlertDialog saveDialog = new AlertDialog.Builder(this).setTitle(R.string.save_dialog_title) .setView(input).setPositiveButton(R.string.dialog_positive, null) .setNegativeButton(R.string.dialog_negative, null).create(); saveDialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { Button b = saveDialog.getButton(AlertDialog.BUTTON_POSITIVE); b.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String value = input.getText().toString(); if (!value.equals("")) { controller.handleMessage(GraphController.MESSAGE_SAVE_GRAPH, value); saveDialog.dismiss(); } } }); } }); saveDialog.show(); break; default: return super.onOptionsItemSelected(item); } return true; }