List of usage examples for android.app Dialog setContentView
public void setContentView(@NonNull View view)
From source file:com.thingsee.tracker.MainActivity.java
@Override public void onMapReady(GoogleMap map) { mMap = map;/*from w w w. ja v a 2s . c om*/ TileProvider wmsTileProvider = TileProviderFactory.getKapsiWmsTileProvider(); mMap.addTileOverlay(new TileOverlayOptions().tileProvider(wmsTileProvider).fadeIn(true)); initGoogleMap(); trackerList = (HorizontalScrollView) this.findViewById(R.id.tracker_scroll_area); mTrackerItemLayout = (LinearLayout) findViewById(R.id.trackers); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mainari, 16)); Marker mark = mMap.addMarker(new MarkerOptions().position(mainari)); ImageView locateButton = (ImageView) findViewById(R.id.app_icon); //set the ontouch listener locateButton.setOnTouchListener(new OnTouchListener() { @SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: { ImageView view = (ImageView) v; view.getDrawable().setColorFilter(0x77000000, PorterDuff.Mode.SRC_ATOP); view.invalidate(); break; } case MotionEvent.ACTION_UP: if (onChildOnMapView) { onUpPressed(); } else { userZoomAndPanOnMap = false; zoomToBoundingBox(); } case MotionEvent.ACTION_CANCEL: { ImageView view = (ImageView) v; //clear the overlay view.getDrawable().setColorFilter(mResources.getColor(R.color.white_effect), PorterDuff.Mode.SRC_ATOP); view.invalidate(); break; } } return true; } }); ImageView settingsButton = (ImageView) findViewById(R.id.header_settings_icon); //set the ontouch listener settingsButton.setOnTouchListener(new OnTouchListener() { @SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: { ImageView view = (ImageView) v; //overlay is black with transparency of 0x77 (119) view.getDrawable().setColorFilter(0x77000000, PorterDuff.Mode.SRC_ATOP); view.invalidate(); break; } case MotionEvent.ACTION_UP: final Dialog verificationQuery = new Dialog(mContext, android.R.style.Theme_Translucent_NoTitleBar); verificationQuery.requestWindowFeature(Window.FEATURE_NO_TITLE); verificationQuery.setCancelable(false); verificationQuery.setContentView(R.layout.request_admin_code); ClearTextView ok = (ClearTextView) verificationQuery.findViewById(R.id.ok); ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { verificationQuery.dismiss(); EditText code = (EditText) verificationQuery.findViewById(R.id.verification_code); if (code.getText().toString().equalsIgnoreCase("password")) { Intent intent = new Intent(MainActivity.this, MenuActivity.class); startActivity(intent); } } }); ClearTextView cancel = (ClearTextView) verificationQuery.findViewById(R.id.cancel); cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { verificationQuery.dismiss(); } }); verificationQuery.show(); verificationQuery.getWindow().setDimAmount(0.5f); verificationQuery.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); case MotionEvent.ACTION_CANCEL: { ImageView view = (ImageView) v; //clear the overlay view.getDrawable().setColorFilter(mResources.getColor(R.color.white_effect), PorterDuff.Mode.SRC_ATOP); view.invalidate(); break; } } return true; } }); mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() { @Override public void onMapClick(LatLng position) { if (onChildOnMapView) { if (trackerModelWithMarker != null) { trackerModelWithMarker.getMarker().showInfoWindow(); } } } }); mMap.setOnMarkerClickListener(new OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker marker) { if (trackersActive) { LatLng latlng = marker.getPosition(); userZoomAndPanOnMap = false; if ((latlng.latitude == mainari.latitude) && (latlng.longitude == mainari.longitude)) { if (onChildOnMapView) { if (trackerModelWithMarker != null) { trackerModelWithMarker.getMarker().showInfoWindow(); } } } else { if (!onChildOnMapView) { trackerModelWithMarker = null; // Zoom to marker tapped zoomToMarker(latlng); //Remove other markers for (String key : trackers.keySet()) { TrackerModel trackerModel = trackers.get(key); if (trackerModel.getLatestLatLng() != null) { if ((trackerModel.getLatestLatLng().latitude == latlng.latitude) && (trackerModel.getLatestLatLng().longitude == latlng.longitude)) { focusOnChildOnMap(trackerModel.getSerialNumber()); trackerModelWithMarker = trackerModel; trackerModelWithMarker.getMarker().showInfoWindow(); } } } } else { trackerModelWithMarker.getMarker().showInfoWindow(); for (String key : trackers.keySet()) { TrackerModel trackerModel = trackers.get(key); if (trackerModel.getLatestLatLng() != null) { if ((trackerModel.getLatestLatLng().latitude == latlng.latitude) && (trackerModel.getLatestLatLng().longitude == latlng.longitude)) { onBackPressed(); } } } } } } return true; } }); mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { // Use default InfoWindow frame @Override public View getInfoWindow(Marker arg0) { return null; } // Defines the contents of the InfoWindow @Override public View getInfoContents(Marker arg0) { // Getting view from the layout file info_window_layout View v = null; for (String key : trackers.keySet()) { TrackerModel trackerModel = trackers.get(key); if (trackerModel.getLatestLatLng() != null) { if ((trackerModel.getLatestLatLng().latitude == arg0.getPosition().latitude) && (trackerModel.getLatestLatLng().longitude == arg0.getPosition().longitude)) { v = getLayoutInflater().inflate(R.layout.info_window, null); trackerModelWithMarker = trackerModel; TextView trackerAccuracy = (TextView) v .findViewById(R.id.tracker_marker_popup_accuracy); if (trackerModelWithMarker.getAccuracy() != -1) { trackerAccuracy .setText(String.format(mResources.getString(R.string.tracker_accuracy), trackerModelWithMarker.getAccuracy())); } else { trackerAccuracy.setText( String.format(mResources.getString(R.string.tracker_accuracy), 0.0f)); } TextView trackerDistanceTs = (TextView) v .findViewById(R.id.tracker_marker_popup_update_timestamp); if (trackerModelWithMarker.getLastLocationUpdate() != 0) { String timeStampText = Utilities.getSmartTimeStampString(mContext, mResources, trackerModelWithMarker.getLastLocationUpdate()); trackerDistanceTs.setText( mResources.getString(R.string.tracker_timestamp) + " " + timeStampText); } else { trackerDistanceTs.setText(mResources.getString(R.string.tracker_timestamp) + " - "); } trackerInfoWindow = v; } } } // Returning the view containing InfoWindow contents return v; } }); IntentFilter statusIntentFilter = new IntentFilter(CommonConstants.BROADCAST_ACTION); statusIntentFilter.addCategory(Intent.CATEGORY_DEFAULT); mFetchCloudDataStateReceiver = new FetchCloudDataStateReceiver(); LocalBroadcastManager.getInstance(this).registerReceiver(mFetchCloudDataStateReceiver, statusIntentFilter); mapLoaded = true; if (splashReady) { mSplashHandler.postDelayed(splashScreenOffFromDisplay, 0); } }
From source file:org.connectbot.ConsoleFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.disconnect: { // disconnect or close the currently visible session final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); final TerminalBridge bridge = terminalView.bridge; bridge.dispatchDisconnect(true); return true; }/* w w w . j av a 2 s . c o m*/ case R.id.copy: { // mark as copying and reset any previous bounds final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); copySource = terminalView.bridge; final SelectionArea area = copySource.getSelectionArea(); area.reset(); area.setBounds(copySource.buffer.getColumns(), copySource.buffer.getRows()); copySource.setSelectingForCopy(true); // Make sure we show the initial selection copySource.redraw(); Toast.makeText(getActivity(), getString(R.string.console_copy_start), Toast.LENGTH_LONG).show(); return true; } case R.id.paste: { // force insert of clipboard text into current console final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); final TerminalBridge bridge = terminalView.bridge; // pull string from clipboard and generate all events to force down final String clip = clipboard.getText().toString(); bridge.injectString(clip); return true; } case R.id.port_forwards: { final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); final TerminalBridge bridge = terminalView.bridge; final Intent intent = new Intent(getActivity(), PortForwardListActivity.class); intent.putExtra(Intent.EXTRA_TITLE, bridge.host.getId()); startActivityForResult(intent, REQUEST_EDIT); return true; } case R.id.url_scan: { final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); final List<String> urls = terminalView.bridge.scanForURLs(); final Dialog urlDialog = new Dialog(getActivity()); urlDialog.setTitle(R.string.console_menu_urlscan); ListView urlListView = new ListView(getActivity()); final URLItemListener urlListener = new URLItemListener(getActivity()); urlListView.setOnItemClickListener(urlListener); urlListView .setAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, urls)); urlDialog.setContentView(urlListView); urlDialog.show(); return true; } case R.id.resize: { final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); final View resizeView = inflater.inflate(R.layout.dia_resize, null, false); new AlertDialog.Builder(getActivity()).setView(resizeView) .setPositiveButton(R.string.button_resize, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { final int width, height; try { width = Integer.parseInt( ((EditText) resizeView.findViewById(R.id.width)).getText().toString()); height = Integer.parseInt( ((EditText) resizeView.findViewById(R.id.height)).getText().toString()); } catch (NumberFormatException nfe) { // TODO change this to a real dialog where we can // make the input boxes turn red to indicate an error. return; } terminalView.forceSize(width, height); } }).setNegativeButton(android.R.string.cancel, null).create().show(); return true; } default: return super.onOptionsItemSelected(item); } }
From source file:com.alivenet.dmv.driverapplication.fragment.MyAccount.java
public void showActionSheet() { LayoutInflater inflater = LayoutInflater.from(getActivity()); final Dialog myDialog = new Dialog(getActivity(), android.R.style.Theme_Translucent_NoTitleBar); myDialog.setCanceledOnTouchOutside(true); myDialog.getWindow().setLayout(AbsoluteLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); myDialog.getWindow().setGravity(Gravity.BOTTOM); myDialog.getWindow().getAttributes().windowAnimations = R.anim.slide_up; WindowManager.LayoutParams lp = myDialog.getWindow().getAttributes(); lp.dimAmount = 0.75f;/*from w ww. j ava 2 s.c o m*/ myDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); myDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); myDialog.getWindow(); View dialoglayout = inflater.inflate(R.layout.dialog_profile_actionsheet, null); myDialog.setContentView(dialoglayout); TextView mTvTakeFromCamera = (TextView) myDialog.findViewById(R.id.tvTakeFromCamera); TextView mTvTakeFromLibrary = (TextView) myDialog.findViewById(R.id.tvTakeFromLibrary); long timestamp = System.currentTimeMillis(); AppData.getSingletonObject().setmFileTemp(getActivity(), "" + timestamp); mTvTakeFromCamera.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { myDialog.dismiss(); takePicture(getActivity()); } }); mTvTakeFromLibrary.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { myDialog.dismiss(); openGallery(getActivity()); } }); TextView tvCancel = (TextView) myDialog.findViewById(R.id.tvCancel); tvCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { myDialog.dismiss(); } }); try { myDialog.show(); } catch (WindowManager.BadTokenException e) { Log.e("", "View not attached."); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.gpsmobitrack.gpstracker.MenuItems.SettingsPage.java
/** * Profile is Public ON or OFF /*w w w . ja v a2 s. c o m*/ */ private void showPublicAlert(String Message, String Title, final int alertCode) { final Dialog dialog = new Dialog(getActivity(), android.R.style.Theme_Translucent); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(false); dialog.setContentView(R.layout.alert_dialog_main); final TextView alertTitle = (TextView) dialog.findViewById(R.id.alert_title); final TextView alertMsg = (TextView) dialog.findViewById(R.id.alert_msg); final EditText alertEditTxt = (EditText) dialog.findViewById(R.id.alert_edit_txt); Button okBtn = (Button) dialog.findViewById(R.id.alert_ok_btn); Button cancelBtn = (Button) dialog.findViewById(R.id.alert_cancel_btn); alertTitle.setText(Title); alertMsg.setText(Message); alertEditTxt.setVisibility(View.GONE); cancelBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); if (alertCode == 7) { publicPrivacy.setChecked(true); editor.putBoolean(AppConstants.IS_ENABLED_PROFILE_PRIVACY, true); editor.commit(); } } }); okBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); if (alertCode == 7) { publicPrivacy.setChecked(false); editor.putBoolean(AppConstants.IS_ENABLED_PROFILE_PRIVACY, false); editor.commit(); } } }); dialog.show(); }
From source file:com.gpsmobitrack.gpstracker.MenuItems.SettingsPage.java
/** * Background updates show ON or OFF//www . j av a 2 s . c om */ private void showAlert(String Message, String Title, final int alertCode) { final Dialog dialog = new Dialog(getActivity(), android.R.style.Theme_Translucent); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(false); dialog.setContentView(R.layout.alert_dialog_main); final TextView alertTitle = (TextView) dialog.findViewById(R.id.alert_title); final TextView alertMsg = (TextView) dialog.findViewById(R.id.alert_msg); final EditText alertEditTxt = (EditText) dialog.findViewById(R.id.alert_edit_txt); Button okBtn = (Button) dialog.findViewById(R.id.alert_ok_btn); Button cancelBtn = (Button) dialog.findViewById(R.id.alert_cancel_btn); alertTitle.setText(Title); alertMsg.setText(Message); alertEditTxt.setVisibility(View.GONE); if (alertCode == 0 || alertCode == UPDATE_INT || alertCode == 7) { cancelBtn.setVisibility(View.VISIBLE); } else { cancelBtn.setVisibility(View.GONE); } cancelBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); if (alertCode == 7) { backUpdateToggle.setChecked(true); editor.putBoolean(AppConstants.IS_SERVICE_ENABLED_PREF, true); editor.commit(); } } }); okBtn.setOnClickListener(new OnClickListener() { @SuppressWarnings("unused") @Override public void onClick(View v) { dialog.dismiss(); if (alertCode == 3 || alertCode == 4) { session.logoutUser(getActivity()); Intent i = new Intent(getActivity(), Login.class); startActivity(i); getActivity().finish(); } else if (alertCode == 0) { deactivateAcc(); } else if (alertCode == UPDATE_INT) { getActivity().finish(); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=com.gpstracker.pro")); startActivity(intent); } else if (alertCode == 7) { backUpdateToggle.setChecked(false); editor.putBoolean(AppConstants.IS_SERVICE_ENABLED_PREF, false); editor.commit(); AlarmManager alarm = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE); Calendar cal = Calendar.getInstance(); Intent intent2 = new Intent(getActivity(), BackgroundService.class); PendingIntent pintent = PendingIntent.getService(getActivity(), 0, intent2, 0); if (PendingIntent.getService(getActivity(), 0, intent2, PendingIntent.FLAG_NO_CREATE) != null) { alarm.cancel(pintent); } } } }); dialog.show(); }
From source file:com.hughes.android.dictionary.DictionaryActivity.java
void onSearchTextChange(final String text) { if ("thadolina".equals(text)) { final Dialog dialog = new Dialog(getListView().getContext()); dialog.setContentView(R.layout.thadolina_dialog); dialog.setTitle("Ti amo, amore mio!"); final ImageView imageView = (ImageView) dialog.findViewById(R.id.thadolina_image); imageView.setOnClickListener(new OnClickListener() { @Override/*from w ww. jav a 2s . c o m*/ public void onClick(View v) { final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("https://sites.google.com/site/cfoxroxvday/vday2012")); startActivity(intent); } }); dialog.show(); } if (dictRaf == null) { Log.d(LOG, "searchText changed during shutdown, doing nothing."); return; } // if (!searchView.hasFocus()) { // Log.d(LOG, "searchText changed without focus, doing nothing."); // return; // } Log.d(LOG, "onSearchTextChange: " + text); if (currentSearchOperation != null) { Log.d(LOG, "Interrupting currentSearchOperation."); currentSearchOperation.interrupted.set(true); } currentSearchOperation = new SearchOperation(text, index); searchExecutor.execute(currentSearchOperation); }
From source file:com.hughes.android.dictionary.DictionaryActivity.java
void onLanguageButtonLongClick(final Context context) { final Dialog dialog = new Dialog(context); dialog.setContentView(R.layout.select_dictionary_dialog); dialog.setTitle(R.string.selectDictionary); final List<DictionaryInfo> installedDicts = application.getDictionariesOnDevice(null); ListView listView = (ListView) dialog.findViewById(android.R.id.list); final Button button = new Button(listView.getContext()); final String name = getString(R.string.dictionaryManager); button.setText(name);// w ww .ja v a 2 s . c o m final IntentLauncher intentLauncher = new IntentLauncher(listView.getContext(), DictionaryManagerActivity.getLaunchIntent(getApplicationContext())) { @Override protected void onGo() { dialog.dismiss(); DictionaryActivity.this.finish(); } }; button.setOnClickListener(intentLauncher); listView.addHeaderView(button); listView.setAdapter(new BaseAdapter() { @Override public View getView(int position, View convertView, ViewGroup parent) { final DictionaryInfo dictionaryInfo = getItem(position); final LinearLayout result = new LinearLayout(parent.getContext()); for (int i = 0; i < dictionaryInfo.indexInfos.size(); ++i) { final IndexInfo indexInfo = dictionaryInfo.indexInfos.get(i); final View button = application.createButton(parent.getContext(), dictionaryInfo, indexInfo); final IntentLauncher intentLauncher = new IntentLauncher(parent.getContext(), getLaunchIntent(getApplicationContext(), application.getPath(dictionaryInfo.uncompressedFilename), indexInfo.shortName, searchView.getQuery().toString())) { @Override protected void onGo() { dialog.dismiss(); DictionaryActivity.this.finish(); } }; button.setOnClickListener(intentLauncher); if (i == indexIndex && dictFile != null && dictFile.getName().equals(dictionaryInfo.uncompressedFilename)) { button.setPressed(true); } result.addView(button); } final TextView nameView = new TextView(parent.getContext()); final String name = application.getDictionaryName(dictionaryInfo.uncompressedFilename); nameView.setText(name); final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.width = 0; layoutParams.weight = 1.0f; nameView.setLayoutParams(layoutParams); nameView.setGravity(Gravity.CENTER_VERTICAL); result.addView(nameView); return result; } @Override public long getItemId(int position) { return position; } @Override public DictionaryInfo getItem(int position) { return installedDicts.get(position); } @Override public int getCount() { return installedDicts.size(); } }); dialog.show(); }
From source file:de.mkrtchyan.recoverytools.RecoveryTools.java
private void showFlashRecoveryDialog() { final Dialog FlashRecoveryDialog = new Dialog(mContext); LayoutInflater inflater = getLayoutInflater(); FlashRecoveryDialog.setTitle(R.string.flash_options); try {//from w w w. java2 s .c om final ScrollView RecoveryLayout = (ScrollView) inflater.inflate(R.layout.recovery_dialog, null); LinearLayout layout = (LinearLayout) RecoveryLayout.getChildAt(0); FlashRecoveryDialog.setContentView(RecoveryLayout); if (!mDevice.isCwmSupported()) { layout.removeView(FlashRecoveryDialog.findViewById(R.id.bCWM)); } if (!mDevice.isTwrpSupported()) { layout.removeView(FlashRecoveryDialog.findViewById(R.id.bTWRP)); } if (!mDevice.isPhilzSupported()) { layout.removeView(FlashRecoveryDialog.findViewById(R.id.bPHILZ)); } FlashRecoveryDialog.show(); } catch (NullPointerException e) { Notifyer.showExceptionToast(mContext, TAG, e); } }
From source file:com.hughes.android.dictionary.DictionaryActivity.java
@Override public boolean onCreateOptionsMenu(final Menu menu) { if (PreferenceManager.getDefaultSharedPreferences(this) .getBoolean(getString(R.string.showPrevNextButtonsKey), true)) { // Next word. nextWordMenuItem = menu.add(getString(R.string.nextWord)).setIcon(R.drawable.arrow_down_float); MenuItemCompat.setShowAsAction(nextWordMenuItem, MenuItem.SHOW_AS_ACTION_IF_ROOM); nextWordMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override//w ww. j a v a 2 s . c o m public boolean onMenuItemClick(MenuItem item) { onUpDownButton(false); return true; } }); // Previous word. previousWordMenuItem = menu.add(getString(R.string.previousWord)).setIcon(R.drawable.arrow_up_float); MenuItemCompat.setShowAsAction(previousWordMenuItem, MenuItem.SHOW_AS_ACTION_IF_ROOM); previousWordMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { onUpDownButton(true); return true; } }); } randomWordMenuItem = menu.add(getString(R.string.randomWord)); randomWordMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { onRandomWordButton(); return true; } }); application.onCreateGlobalOptionsMenu(this, menu); { final MenuItem dictionaryManager = menu.add(getString(R.string.dictionaryManager)); MenuItemCompat.setShowAsAction(dictionaryManager, MenuItem.SHOW_AS_ACTION_NEVER); dictionaryManager.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(final MenuItem menuItem) { startActivity(DictionaryManagerActivity.getLaunchIntent(getApplicationContext())); finish(); return false; } }); } { final MenuItem aboutDictionary = menu.add(getString(R.string.aboutDictionary)); MenuItemCompat.setShowAsAction(aboutDictionary, MenuItem.SHOW_AS_ACTION_NEVER); aboutDictionary.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(final MenuItem menuItem) { final Context context = getListView().getContext(); final Dialog dialog = new Dialog(context); dialog.setContentView(R.layout.about_dictionary_dialog); final TextView textView = (TextView) dialog.findViewById(R.id.text); final String name = application.getDictionaryName(dictFile.getName()); dialog.setTitle(name); final StringBuilder builder = new StringBuilder(); final DictionaryInfo dictionaryInfo = dictionary.getDictionaryInfo(); dictionaryInfo.uncompressedBytes = dictFile.length(); if (dictionaryInfo != null) { builder.append(dictionaryInfo.dictInfo).append("\n\n"); builder.append(getString(R.string.dictionaryPath, dictFile.getPath())).append("\n"); builder.append(getString(R.string.dictionarySize, dictionaryInfo.uncompressedBytes)) .append("\n"); builder.append(getString(R.string.dictionaryCreationTime, dictionaryInfo.creationMillis)) .append("\n"); for (final IndexInfo indexInfo : dictionaryInfo.indexInfos) { builder.append("\n"); builder.append(getString(R.string.indexName, indexInfo.shortName)).append("\n"); builder.append(getString(R.string.mainTokenCount, indexInfo.mainTokenCount)) .append("\n"); } builder.append("\n"); builder.append(getString(R.string.sources)).append("\n"); for (final EntrySource source : dictionary.sources) { builder.append(getString(R.string.sourceInfo, source.getName(), source.getNumEntries())) .append("\n"); } } textView.setText(builder.toString()); dialog.show(); final WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(); layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT; dialog.getWindow().setAttributes(layoutParams); return false; } }); } return true; }
From source file:com.andrewshu.android.reddit.mail.InboxListActivity.java
@Override protected Dialog onCreateDialog(int id) { Dialog dialog; ProgressDialog pdialog;//from w ww . j av a 2s. co m AlertDialog.Builder builder; LayoutInflater inflater; View layout; // used for inflated views for AlertDialog.Builder.setView() switch (id) { case Constants.DIALOG_LOGIN: dialog = new LoginDialog(this, mSettings, true) { @Override public void onLoginChosen(String user, String password) { removeDialog(Constants.DIALOG_LOGIN); new MyLoginTask(user, password).execute(); } }; break; case Constants.DIALOG_REPLY: dialog = new Dialog(this, mSettings.getDialogTheme()); dialog.setContentView(R.layout.compose_reply_dialog); final EditText replyBody = (EditText) dialog.findViewById(R.id.body); final Button replySaveButton = (Button) dialog.findViewById(R.id.reply_save_button); final Button replyCancelButton = (Button) dialog.findViewById(R.id.reply_cancel_button); replySaveButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (mReplyTargetName != null) { new MessageReplyTask(mReplyTargetName).execute(replyBody.getText().toString()); removeDialog(Constants.DIALOG_REPLY); } else { Common.showErrorToast("Error replying. Please try again.", Toast.LENGTH_SHORT, InboxListActivity.this); } } }); replyCancelButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { removeDialog(Constants.DIALOG_REPLY); } }); break; // "Please wait" case Constants.DIALOG_LOGGING_IN: pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme())); pdialog.setMessage("Logging in..."); pdialog.setIndeterminate(true); pdialog.setCancelable(true); dialog = pdialog; break; case Constants.DIALOG_REPLYING: pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme())); pdialog.setMessage("Sending reply..."); pdialog.setIndeterminate(true); pdialog.setCancelable(true); dialog = pdialog; break; default: throw new IllegalArgumentException("Unexpected dialog id " + id); } return dialog; }