List of usage examples for android.app Dialog getWindow
public @Nullable Window getWindow()
From source file:info.hl.mediam.GroupProfileActivity.java
private void getImageDialog() { final Dialog imageDialog = new Dialog(GroupProfileActivity.this, R.style.TransparentDialogTheme); imageDialog.getWindow().setGravity(Gravity.BOTTOM); imageDialog.setContentView(R.layout.dialog_get_image); WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(); Window window = imageDialog.getWindow(); layoutParams.copyFrom(window.getAttributes()); layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT; window.setAttributes(layoutParams);// ww w . j a v a2 s . com final Button btnGallery = (Button) imageDialog.findViewById(R.id.btnGallery); btnGallery.setTypeface(MediamApp.getTfMyriadProBold(), Typeface.BOLD); btnGallery.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent galleryIntent = new Intent(GroupProfileActivity.this, CameraCropActivity.class); galleryIntent.putExtra("type", "gallery"); galleryIntent.putExtra("groupUpdate", true); GroupProfileActivity.this.startActivityForResult(galleryIntent, UPDATE_IMAGE_REQUEST_CODE); imageDialog.dismiss(); } }); final Button btnCamera = (Button) imageDialog.findViewById(R.id.btnCamera); btnCamera.setTypeface(MediamApp.getTfMyriadProBold(), Typeface.BOLD); btnCamera.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent cameraIntent = new Intent(GroupProfileActivity.this, CameraCropActivity.class); cameraIntent.putExtra("type", "camera"); cameraIntent.putExtra("groupUpdate", true); GroupProfileActivity.this.startActivityForResult(cameraIntent, UPDATE_IMAGE_REQUEST_CODE); imageDialog.dismiss(); } }); final Button btnRemovePhoto = (Button) imageDialog.findViewById(R.id.btnRemovePhoto); btnRemovePhoto.setTypeface(MediamApp.getTfMyriadProBold(), Typeface.BOLD); btnRemovePhoto.setOnClickListener(new OnClickListener() { public void onClick(View v) { mGroupAvatarId = ""; gGroupImage = null; Utils.displayImage(mGroupAvatarId, mIvGroupImage, mPbLoading, ImageLoader.LARGE, R.drawable.group_stub_large, false); imageDialog.dismiss(); } }); imageDialog.show(); }
From source file:com.undatech.opaque.RemoteCanvasActivity.java
/** * Creates the help dialog for this activity. *//*from ww w.ja v a 2 s .c o m*/ private Dialog createHelpDialog() { AlertDialog.Builder adb = new AlertDialog.Builder(this).setMessage(R.string.input_method_help_text) .setPositiveButton(R.string.close, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // We don't have to do anything. } }); Dialog d = adb.setView(new ListView(this)).create(); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(d.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.FILL_PARENT; lp.height = WindowManager.LayoutParams.WRAP_CONTENT; d.show(); d.getWindow().setAttributes(lp); return d; }
From source file:Steps.StepsFragment.java
private void showNewSticker(final Sticker sticker_1, final Sticker sticker_2, final Sticker sticker_3) { // custom dialog final Dialog dialog = new Dialog(getActivity()); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override/*from w ww. j a v a 2 s . c o m*/ public void onCancel(DialogInterface dialog) { dialog.dismiss(); } }); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); dialog.setContentView(R.layout.new_stickers_dialog); //get the correct image -1st sticker ImageView image = (ImageView) (dialog).findViewById(R.id.sticker1); image.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showStickerMoreInfo(sticker_1); } }); String file = sticker_1.getImagesrc(); file = file.substring(0, file.lastIndexOf(".")); //trim the extension Resources resources = getActivity().getResources(); int resourceId = resources.getIdentifier(file, "drawable", getActivity().getPackageName()); TextView number = (TextView) (dialog).findViewById(R.id.text_sticker1); number.setText("#" + Integer.toString(sticker_1.getId())); RelativeLayout image_layout = (RelativeLayout) (dialog).findViewById(R.id.sticker1_layout); ImageView imageCategory = (ImageView) (dialog).findViewById(R.id.category_image1); determineCategoty(imageCategory, sticker_1); determinePicture(sticker_1, image, resourceId); animate(image_layout, 3000); //get the correct image -2nd sticker ImageView image2 = (ImageView) (dialog).findViewById(R.id.sticker2); image2.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showStickerMoreInfo(sticker_2); } }); String file2 = sticker_2.getImagesrc(); file2 = file2.substring(0, file2.lastIndexOf(".")); //trim the extension Resources resources2 = getActivity().getResources(); int resourceId2 = resources2.getIdentifier(file2, "drawable", getActivity().getPackageName()); TextView number2 = (TextView) (dialog).findViewById(R.id.text_sticker2); number2.setText("#" + Integer.toString(sticker_2.getId())); RelativeLayout image_layout2 = (RelativeLayout) (dialog).findViewById(R.id.sticker2_layout); ImageView imageCategory2 = (ImageView) (dialog).findViewById(R.id.category_image2); determineCategoty(imageCategory2, sticker_2); determinePicture(sticker_2, image2, resourceId2); animate(image_layout2, 3000); //get the correct image -3rd sticker ImageView image3 = (ImageView) (dialog).findViewById(R.id.sticker3); image3.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showStickerMoreInfo(sticker_3); } }); String file3 = sticker_3.getImagesrc(); file3 = file3.substring(0, file3.lastIndexOf(".")); //trim the extension Resources resources3 = getActivity().getResources(); int resourceId3 = resources3.getIdentifier(file3, "drawable", getActivity().getPackageName()); TextView number3 = (TextView) (dialog).findViewById(R.id.text_sticker3); number3.setText("#" + Integer.toString(sticker_3.getId())); RelativeLayout image_layout3 = (RelativeLayout) (dialog).findViewById(R.id.sticker3_layout); ImageView imageCategory3 = (ImageView) (dialog).findViewById(R.id.category_image3); determineCategoty(imageCategory3, sticker_3); determinePicture(sticker_3, image3, resourceId3); animate(image_layout3, 3000); Display display = getActivity().getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); int width = size.x; int height = size.y; //set the layout to have the same widh and height as the windows screen WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = width; lp.height = height; dialog.getWindow().setAttributes(lp); RelativeLayout mainLayout = (RelativeLayout) dialog.findViewById(R.id.showStickerLayout); dialog.show(); // if button is clicked, close the custom dialog Button doneButton = (Button) (dialog).findViewById(R.id.doneButton); doneButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); }
From source file:com.birdeye.MainActivity.java
@Override public boolean onOptionsItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.logout: fullReset();/* www . j a va 2s .c o m*/ startActivity(LoginActivity.create(this)); finish(); return true; case R.id.About: final Dialog dialog2 = new Dialog(MainActivity.this); dialog2.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog2.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); dialog2.setContentView(R.layout.about); dialog2.setCancelable(false); dialog2.show(); return true; case R.id.ShareApp: Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/html"); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml( "<p>Hey, am using this really cool hashtag activated camera app. Get it here #birdeyecamera.</p>")); startActivity(Intent.createChooser(sharingIntent, "Share using")); return true; case R.id.Recommend: Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("BirdEyeCamera", "birdeyecamera@digitalbabi.es", null)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Feature Recommendation"); startActivity(Intent.createChooser(emailIntent, "Send email...")); return true; case R.id.rateApp: final Uri uri = Uri.parse("market://details?id=" + getApplicationContext().getPackageName()); final Intent rateAppIntent = new Intent(Intent.ACTION_VIEW, uri); if (getPackageManager().queryIntentActivities(rateAppIntent, 0).size() > 0) { startActivity(rateAppIntent); } else { /* handle your error case: the device has no way to handle market urls */ } return true; case R.id.RemoveAds: if (Globals.hasPaid) { Toast.makeText(MainActivity.this, "You already are in a premium account", Toast.LENGTH_SHORT) .show(); } else { removeAdsDialog(); } return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.hp.map.CustomerMapActivity.java
public void menuDialog() { final Dialog dialog = new Dialog(this); LayoutInflater li = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = li.inflate(R.layout.menu_dialog, null, false); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(v);// w ww.j a v a 2 s . c o m dialog.setTitle("Danh mc chnh"); Display display = getWindowManager().getDefaultDisplay(); dialog.getWindow().setLayout(2 * display.getWidth() / 3, LayoutParams.FILL_PARENT); dialog.getWindow().getAttributes().gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL; lv = (ListView) dialog.findViewById(R.id.menu_list_view); lv.setAdapter( new DialogArrayAdapter(context, android.R.layout.simple_list_item_1, DetailListData.MENU_LIST)); lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub DetailsList selectedValue = (DetailsList) lv.getAdapter().getItem(arg2); if (selectedValue.activityClass != null) { //if sigout if (selectedValue.activityClass == LoginActivity.class) { //LoginActivity.threadLooper.quit(); } startActivity(new Intent(context, selectedValue.activityClass)); } } }); dialog.show(); // ImageView iv = (ImageView)dialog.findViewById(R.id.menu_list_view); // iv.setImageResource(1); }
From source file:hku.fyp14017.blencode.ui.dialogs.OverwriteRenameDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View dialogView = LayoutInflater.from(context) .inflate(hku.fyp14017.blencode.R.layout.dialog_overwrite_project, null); replaceButton = (RadioButton) dialogView .findViewById(hku.fyp14017.blencode.R.id.dialog_overwrite_project_radio_replace); replaceButton.setOnClickListener(this); renameButton = (RadioButton) dialogView .findViewById(hku.fyp14017.blencode.R.id.dialog_overwrite_project_radio_rename); renameButton.setOnClickListener(this); projectText = (EditText) dialogView.findViewById(hku.fyp14017.blencode.R.id.dialog_overwrite_project_edit); projectText.setText(programName);// w ww.ja va 2 s . c o m projectTextView = (TextView) dialogView .findViewById(hku.fyp14017.blencode.R.id.dialog_overwrite_project_edit_text); projectTextLine = dialogView.findViewById(hku.fyp14017.blencode.R.id.dialog_overwrite_project_edit_line); Dialog dialog = new AlertDialog.Builder(getActivity()).setView(dialogView) .setTitle(hku.fyp14017.blencode.R.string.overwrite_text) .setPositiveButton(hku.fyp14017.blencode.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).setNegativeButton(hku.fyp14017.blencode.R.string.cancel_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(context, hku.fyp14017.blencode.R.string.notification_download_project_cancel, Toast.LENGTH_SHORT).show(); } }) .create(); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); dialog.setOnShowListener(new OnShowListener() { @Override public void onShow(DialogInterface dialog) { Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE); positiveButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { handleOkButton(); } }); } }); dialog.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) { boolean okButtonResult = handleOkButton(); if (okButtonResult) { dismiss(); } return okButtonResult; } else if (keyCode == KeyEvent.KEYCODE_BACK) { Toast.makeText(context, hku.fyp14017.blencode.R.string.notification_download_project_cancel, Toast.LENGTH_SHORT).show(); return true; } return false; } }); return dialog; }
From source file:com.nttec.everychan.http.recaptcha.Recaptcha2fallback.java
@Override public void handle(final Activity activity, final CancellableTask task, final Callback callback) { try {// w ww. j ava 2 s .c o m final HttpClient httpClient = ((HttpChanModule) MainApplication.getInstance().getChanModule(chanName)) .getHttpClient(); final String usingURL = scheme + RECAPTCHA_FALLBACK_URL + publicKey + (sToken != null && sToken.length() > 0 ? ("&stoken=" + sToken) : ""); String refererURL = baseUrl != null && baseUrl.length() > 0 ? baseUrl : usingURL; Header[] customHeaders = new Header[] { new BasicHeader(HttpHeaders.REFERER, refererURL) }; String htmlChallenge; if (lastChallenge != null && lastChallenge.getLeft().equals(usingURL)) { htmlChallenge = lastChallenge.getRight(); } else { htmlChallenge = HttpStreamer.getInstance().getStringFromUrl(usingURL, HttpRequestModel.builder().setGET().setCustomHeaders(customHeaders).build(), httpClient, null, task, false); } lastChallenge = null; Matcher challengeMatcher = Pattern.compile("name=\"c\" value=\"([\\w-]+)").matcher(htmlChallenge); if (challengeMatcher.find()) { final String challenge = challengeMatcher.group(1); HttpResponseModel responseModel = HttpStreamer.getInstance().getFromUrl( scheme + RECAPTCHA_IMAGE_URL + challenge + "&k=" + publicKey, HttpRequestModel.builder().setGET().setCustomHeaders(customHeaders).build(), httpClient, null, task); try { InputStream imageStream = responseModel.stream; final Bitmap challengeBitmap = BitmapFactory.decodeStream(imageStream); final String message; Matcher messageMatcher = Pattern.compile("imageselect-message(?:.*?)>(.*?)</div>") .matcher(htmlChallenge); if (messageMatcher.find()) message = RegexUtils.removeHtmlTags(messageMatcher.group(1)); else message = null; final Bitmap candidateBitmap; Matcher candidateMatcher = Pattern .compile("fbc-imageselect-candidates(?:.*?)src=\"data:image/(?:.*?);base64,([^\"]*)\"") .matcher(htmlChallenge); if (candidateMatcher.find()) { Bitmap bmp = null; try { byte[] imgData = Base64.decode(candidateMatcher.group(1), Base64.DEFAULT); bmp = BitmapFactory.decodeByteArray(imgData, 0, imgData.length); } catch (Exception e) { } candidateBitmap = bmp; } else candidateBitmap = null; activity.runOnUiThread(new Runnable() { final int maxX = 3; final int maxY = 3; final boolean[] isSelected = new boolean[maxX * maxY]; @SuppressLint("InlinedApi") @Override public void run() { LinearLayout rootLayout = new LinearLayout(activity); rootLayout.setOrientation(LinearLayout.VERTICAL); if (candidateBitmap != null) { ImageView candidateView = new ImageView(activity); candidateView.setImageBitmap(candidateBitmap); int picSize = (int) (activity.getResources().getDisplayMetrics().density * 50 + 0.5f); candidateView.setLayoutParams(new LinearLayout.LayoutParams(picSize, picSize)); candidateView.setScaleType(ImageView.ScaleType.FIT_XY); rootLayout.addView(candidateView); } if (message != null) { TextView textView = new TextView(activity); textView.setText(message); CompatibilityUtils.setTextAppearance(textView, android.R.style.TextAppearance); textView.setLayoutParams( new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); rootLayout.addView(textView); } FrameLayout frame = new FrameLayout(activity); frame.setLayoutParams( new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); final ImageView imageView = new ImageView(activity); imageView.setLayoutParams(new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setImageBitmap(challengeBitmap); frame.addView(imageView); final LinearLayout selector = new LinearLayout(activity); selector.setLayoutParams(new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); AppearanceUtils.callWhenLoaded(imageView, new Runnable() { @Override public void run() { selector.setLayoutParams(new FrameLayout.LayoutParams(imageView.getWidth(), imageView.getHeight())); } }); selector.setOrientation(LinearLayout.VERTICAL); selector.setWeightSum(maxY); for (int y = 0; y < maxY; ++y) { LinearLayout subSelector = new LinearLayout(activity); subSelector.setLayoutParams(new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f)); subSelector.setOrientation(LinearLayout.HORIZONTAL); subSelector.setWeightSum(maxX); for (int x = 0; x < maxX; ++x) { FrameLayout switcher = new FrameLayout(activity); switcher.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1f)); switcher.setTag(new int[] { x, y }); switcher.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int[] coord = (int[]) v.getTag(); int index = coord[1] * maxX + coord[0]; isSelected[index] = !isSelected[index]; v.setBackgroundColor(isSelected[index] ? Color.argb(128, 0, 255, 0) : Color.TRANSPARENT); } }); subSelector.addView(switcher); } selector.addView(subSelector); } frame.addView(selector); rootLayout.addView(frame); Button checkButton = new Button(activity); checkButton.setLayoutParams( new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); checkButton.setText(android.R.string.ok); rootLayout.addView(checkButton); ScrollView dlgView = new ScrollView(activity); dlgView.addView(rootLayout); final Dialog dialog = new Dialog(activity); dialog.setTitle("Recaptcha"); dialog.setContentView(dlgView); dialog.setCanceledOnTouchOutside(false); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (!task.isCancelled()) { callback.onError("Cancelled"); } } }); dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); dialog.show(); checkButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); if (task.isCancelled()) return; Async.runAsync(new Runnable() { @Override public void run() { try { List<NameValuePair> pairs = new ArrayList<NameValuePair>(); pairs.add(new BasicNameValuePair("c", challenge)); for (int i = 0; i < isSelected.length; ++i) if (isSelected[i]) pairs.add(new BasicNameValuePair("response", Integer.toString(i))); HttpRequestModel request = HttpRequestModel.builder() .setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")) .setCustomHeaders(new Header[] { new BasicHeader(HttpHeaders.REFERER, usingURL) }) .build(); String response = HttpStreamer.getInstance().getStringFromUrl( usingURL, request, httpClient, null, task, false); String hash = ""; Matcher matcher = Pattern.compile( "fbc-verification-token(?:.*?)<textarea[^>]*>([^<]*)<", Pattern.DOTALL).matcher(response); if (matcher.find()) hash = matcher.group(1); if (hash.length() > 0) { Recaptcha2solved.push(publicKey, hash); activity.runOnUiThread(new Runnable() { @Override public void run() { callback.onSuccess(); } }); } else { lastChallenge = Pair.of(usingURL, response); throw new RecaptchaException( "incorrect answer (hash is empty)"); } } catch (final Exception e) { Logger.e(TAG, e); if (task.isCancelled()) return; handle(activity, task, callback); } } }); } }); } }); } finally { responseModel.release(); } } else throw new Exception("can't parse recaptcha challenge answer"); } catch (final Exception e) { Logger.e(TAG, e); if (!task.isCancelled()) { activity.runOnUiThread(new Runnable() { @Override public void run() { callback.onError(e.getMessage() != null ? e.getMessage() : e.toString()); } }); } } }
From source file:net.momodalo.app.vimtouch.VimTouch.java
public void showCmdHistory() { final Dialog dialog = new Dialog(this, R.style.DialogSlideAnim); // Setting dialogview Window window = dialog.getWindow(); window.setGravity(Gravity.BOTTOM);/*from www . j ava 2s . c om*/ window.setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); dialog.setTitle(null); dialog.setContentView(R.layout.hist_list); dialog.setCancelable(true); LinearLayout layout = (LinearLayout) dialog.findViewById(R.id.hist_layout); if (AndroidCompat.SDK >= 11) { layout.setShowDividers(LinearLayout.SHOW_DIVIDER_BEGINNING | LinearLayout.SHOW_DIVIDER_MIDDLE | LinearLayout.SHOW_DIVIDER_END); } LayoutParams params = layout.getLayoutParams(); params.width = mScreenWidth; layout.setLayoutParams(params); LayoutInflater inflater = LayoutInflater.from(this); boolean exists = false; for (int i = 1; i <= 10; i++) { TextView button = (TextView) inflater.inflate(R.layout.histbutton, layout, false); String cmd = Exec.getCmdHistory(i); if (cmd.length() == 0) break; exists = true; button.setText(":" + cmd); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { TextView text = (TextView) v; CharSequence cmd = text.getText(); Exec.doCommand(cmd.subSequence(1, cmd.length()).toString()); dialog.dismiss(); } }); layout.addView((View) button); } if (exists) dialog.show(); }
From source file:su.comp.bk.ui.BkEmuActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_COMPUTER_MODEL: final CharSequence[] models; List<String> modelList = new ArrayList<String>(); for (Configuration model : Configuration.values()) { int modelNameId = getResources().getIdentifier(model.name().toLowerCase(), "string", getPackageName());//w w w. java2 s . co m modelList.add((modelNameId != 0) ? getString(modelNameId) : model.name()); } models = modelList.toArray(new String[modelList.size()]); return new AlertDialog.Builder(this).setTitle(R.string.menu_select_model).setSingleChoiceItems(models, getComputerConfiguration().ordinal(), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Mark selected item by tag ListView listView = ((AlertDialog) dialog).getListView(); listView.setTag(Integer.valueOf(which)); } }).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Get tagged selected item, if any ListView listView = ((AlertDialog) dialog).getListView(); Integer selected = (Integer) listView.getTag(); if (selected != null) { Configuration config = Configuration.values()[selected]; if (computer.getConfiguration() != config) { // Set new computer configuration and restart activity setComputerConfiguration(config); restartActivity(null); } } } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing on cancel } }).create(); case DIALOG_ABOUT: Dialog aboutDialog = new Dialog(this); aboutDialog.setTitle(R.string.menu_about); aboutDialog.requestWindowFeature(Window.FEATURE_LEFT_ICON); aboutDialog.setContentView(R.layout.about_dialog); aboutDialog.getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, android.R.drawable.ic_dialog_info); TextView versionTextView = (TextView) aboutDialog.findViewById(R.id.about_version); try { versionTextView.setText(getResources().getString(R.string.about_version, getPackageManager().getPackageInfo(getPackageName(), 0).versionName)); } catch (NameNotFoundException e) { } return aboutDialog; case DIALOG_DISK_MANAGER: Dialog fddManagerDialog = new Dialog(this); fddManagerDialog.setTitle(R.string.menu_disk_manager); fddManagerDialog.setContentView(R.layout.fdd_mgr_dialog); return fddManagerDialog; case DIALOG_DISK_MOUNT_ERROR: return new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert).setTitle(R.string.err) .setMessage(R.string.dialog_disk_mount_error).setPositiveButton(R.string.ok, null).create(); } return null; }