List of usage examples for android.app Dialog Dialog
public Dialog(@NonNull Context context)
From source file:com.example.gemswin.screencastrecevertest.MainActivity_Reciever.java
protected void DoubtBox1 () { // TODO Auto-generated method stub dialogDoubt1 = new Dialog(MainActivity_Reciever.this); dialogDoubt1.requestWindowFeature(Window.FEATURE_NO_TITLE); dialogDoubt1.setContentView(R.layout.activity_doubtlist_reciever); //here mainListView = (ListView)dialogDoubt1.findViewById(R.id.mainListView); //list ki shuruat /*String[] planets = new String[] { "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"}; planetList.addAll( Arrays.asList(planets) );*/ // Create ArrayAdapter using the planet list. listAdapter = new ArrayAdapter<String>(MainActivity_Reciever.this, R.layout.simplerow_reciever, planetList); mainListView.setAdapter(listAdapter); mainListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int pos, long id) { // TODO Auto-generated method stub itemValue = (String) mainListView.getItemAtPosition(pos); DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override//from w w w .j a v a 2 s . c o m public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: new delete().execute(); break; case DialogInterface.BUTTON_NEGATIVE: //No button clicked break; } } }; AlertDialog.Builder builder = new AlertDialog.Builder(arg1.getContext()); builder.setMessage("Are you sure to delete this doubt ?").setPositiveButton("Yes", dialogClickListener) .setNegativeButton("No", dialogClickListener).show(); return true; } }); dialogDoubt1.show(); }
From source file:com.yammy.meter.MainActivity.java
private void showAlert() { final Dialog myDialog = new Dialog(this); myDialog.setContentView(R.layout.isvo_dialog_low_oil); myDialog.setCancelable(true);//from w w w . j a v a 2 s .com myDialog.setTitle("Peringatan!"); Button batal = (Button) myDialog.findViewById(R.id.dialog_low_oil_cancel); Button cari = (Button) myDialog.findViewById(R.id.dialog_low_oil_cari); myDialog.show(); cari.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(MainActivity.this, MainCari.class); startActivity(i); } }); batal.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { myDialog.cancel(); } }); }
From source file:com.kircherelectronics.gyroscopeexplorer.activity.GyroscopeActivity.java
private void showHelpDialog() { Dialog helpDialog = new Dialog(this); helpDialog.setCancelable(true);// w w w.j a v a2s . com helpDialog.setCanceledOnTouchOutside(true); helpDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); View view = getLayoutInflater().inflate(R.layout.layout_help_home, null); helpDialog.setContentView(view); helpDialog.show(); }
From source file:com.ibm.hellotodo.MainActivity.java
/** * Launches a dialog for adding a new TodoItem. Called when plus button is tapped. * * @param view The plus button that is tapped. *//*w w w .j a v a 2 s. c o m*/ public void addTodo(View view) { final Dialog addDialog = new Dialog(this); addDialog.setContentView(R.layout.add_edit_dialog); addDialog.setTitle("Add Todo"); TextView textView = (TextView) addDialog.findViewById(android.R.id.title); if (textView != null) { textView.setGravity(Gravity.CENTER); } addDialog.setCancelable(true); Button add = (Button) addDialog.findViewById(R.id.Add); addDialog.show(); // When done is pressed, send POST request to create TodoItem on Bluemix add.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { EditText itemToAdd = (EditText) addDialog.findViewById(R.id.todo); final String name = itemToAdd.getText().toString(); // If text was added, continue with normal operations if (!name.isEmpty()) { // Create JSON for new TodoItem, id should be 0 for new items String json = "{\"text\":\"" + name + "\",\"isDone\":false,\"id\":0}"; // Create POST request with IBM Mobile First SDK and set HTTP headers so Bluemix knows what to expect in the request Request request = new Request(client.getBluemixAppRoute() + "/api/Items", Request.POST); HashMap headers = new HashMap(); List<String> cType = new ArrayList<>(); cType.add("application/json"); List<String> accept = new ArrayList<>(); accept.add("Application/json"); headers.put("Content-Type", cType); headers.put("Accept", accept); request.setHeaders(headers); request.send(getApplicationContext(), json, new ResponseListener() { // On success, update local list with new TodoItem @Override public void onSuccess(Response response) { Log.i(TAG, "Item created successfully"); loadList(); } // On failure, log errors @Override public void onFailure(Response response, Throwable t, JSONObject extendedInfo) { String errorMessage = ""; if (response != null) { errorMessage += response.toString() + "\n"; } if (t != null) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); t.printStackTrace(pw); errorMessage += "THROWN" + sw.toString() + "\n"; } if (extendedInfo != null) { errorMessage += "EXTENDED_INFO" + extendedInfo.toString() + "\n"; } if (errorMessage.isEmpty()) errorMessage = "Request Failed With Unknown Error."; Log.e(TAG, "addTodo failed with error: " + errorMessage); } }); } // Kill dialog when finished, or if no text was added addDialog.dismiss(); } }); }
From source file:com.chalmers.schmaps.GoogleMapSearchLocation.java
/** * If the enter button is clicked a room search is done * If the get directions button is pressed you get the path drawn on map * but you have to search for a room first *//*from www.j av a 2 s .c om*/ public void onClick(View v) { switch (v.getId()) { case R.id.edittextbutton: //Removes the key when finish typing InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(lectureEdit.getWindowToken(), 0); //removes the path drawn if there is one mapOverlays.remove(pathOverlay); //removes the dot that point to a previous room found mapOverlays.remove(mapItemizedRoom); roomToFind = lectureEdit.getText().toString(); //removes white signs and converts to lower case roomToFind.toLowerCase().trim(); //Removes illegal characters to prevent sql injection roomToFind = roomToFind.replaceAll("[^[a-z][A-Z][0-9]]", ""); //Set the field variable so it can be tested. setRoomToFind(roomToFind); //open database in read mode search.openRead(); //if we find room show room on map, if not show dialog if (search.exists(roomToFind)) { //create a geopoint roomLocation = new GeoPoint(search.getLat(roomToFind), search.getLong(roomToFind)); mapcon = mapView.getController(); mapcon.animateTo(roomLocation); //zoom level mapcon.setZoom(OVERVIEWZOOMVALUE); //address and level is shown in the dialog overlayItemRoom = new OverlayItem(roomLocation, search.getAddress(roomToFind), search.getLevel(roomToFind)); mapItemizedRoom.removeOverlay(); mapItemizedRoom.addOverlay(overlayItemRoom); mapOverlays.add(mapItemizedRoom); mapView.postInvalidate(); //now someone has searched for a room, set the boolean to true roomSearched = true; } else { //dilaog pops up if room not found dialog = new Dialog(GoogleMapSearchLocation.this); dialog.setTitle("Sorry, can not find the room :("); dialog.setCanceledOnTouchOutside(true); dialog.show(); } //close database search.close(); break; case R.id.directionbutton: Log.e("roomsearched", "in"); //if there there is roomLocation then search for a path //if not a roomLocation then the user has not searched for a room, do not give directions if (gotInternetConnection()) { Log.e("roomsearched", "inin"); if (roomSearched) { walkningDirections(); roomSearched = false; } else { Context context = getApplicationContext(); Toast.makeText(context, "Search for a room first to get directions", Toast.LENGTH_LONG).show(); } } else { Context context = getApplicationContext(); Toast.makeText(context, "Internet connection needed for this option", Toast.LENGTH_LONG).show(); } break; } }
From source file:com.slownet5.pgprootexplorer.filemanager.ui.FileManagerActivity.java
private void showBackupDialog() { final Dialog dialog = new Dialog(this); dialog.setContentView(R.layout.password_dialog_layout); Button button = (Button) dialog.findViewById(R.id.decrypt_file_button); button.setText("Backup"); ((TextInputLayout) dialog.findViewById(R.id.key_password_layout)).setHint("Application password"); button.setOnClickListener(new View.OnClickListener() { @Override//from w w w. j av a2s. c o m public void onClick(View view) { String pass = ((EditText) dialog.findViewById(R.id.key_password)).getText().toString(); if (pass.length() < 1) { Toast.makeText(FileManagerActivity.this, "Please input application password", Toast.LENGTH_LONG) .show(); return; } new BackupKeysTask().execute(pass); dialog.dismiss(); } }); dialog.findViewById(R.id.cancel_decrypt_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dialog.dismiss(); } }); dialog.show(); }
From source file:com.openerp.addons.idea.product.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.Dash_Board: Dash_Board detail = new Dash_Board(); FragmentListener frag = (FragmentListener) getActivity(); frag.startDetailFragment(detail); return true; case R.id.Search_product: final Dialog dialog = new Dialog(getActivity()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.product_search_custom_dialog); // dialog.setTitle("Product Search"); dialog.setOnCancelListener(new OnCancelListener() { @Override/*from w w w .j a va 2 s .c o m*/ public void onCancel(DialogInterface dialog) { dialog.dismiss(); } }); AutoCompleteTextView autotext = (AutoCompleteTextView) dialog .findViewById(R.id.autoCompleteTextView_product_search); final ArrayAdapter adapter = new ArrayAdapter(getActivity(), android.R.layout.simple_list_item_1, OEHelper.datatemplate); TextView txv = (TextView) dialog.findViewById(R.id.textView1); Typeface font = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Georgia.ttf"); autotext.setTypeface(font, Typeface.BOLD); autotext.setAdapter(adapter); txv.setTypeface(font, Typeface.BOLD); autotext.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { String name = adapter.getItem(arg2).toString(); callmethod_for_position_productdetail(OEHelper.datatemplate.indexOf(name)); dialog.dismiss(); } }); dialog.show(); return true; } return true; }
From source file:com.android.ex.chips.RecipientEditTextView.java
public RecipientEditTextView(final Context context, final AttributeSet attrs) { super(context, attrs); mAddTextWatcher = new Runnable() { @Override//from ww w. j a v a2 s .c om public void run() { if (mTextWatcher == null) { mTextWatcher = new RecipientTextWatcher(); addTextChangedListener(mTextWatcher); } } }; mDelayedShrink = new Runnable() { @Override public void run() { shrink(); } }; mHandlePendingChips = new Runnable() { @Override public void run() { handlePendingChips(); } }; setChipDimensions(context, attrs); if (sSelectedTextColor == -1) sSelectedTextColor = ContextCompat.getColor(context, android.R.color.white); /*mAlternatesPopup=new ListPopupWindow(context); mAddressPopup=new ListPopupWindow(context);*/ mCopyDialog = new Dialog(context); mAlternatesListener = new OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> adapterView, final View view, final int position, final long rowId) { //mAlternatesPopup.setOnItemClickListener(null); replaceChip(mSelectedChip, ((RecipientAlternatesAdapter) adapterView.getAdapter()).getRecipientEntry(position)); final Message delayed = Message.obtain(mHandler, DISMISS); //delayed.obj=mAlternatesPopup; mHandler.sendMessageDelayed(delayed, DISMISS_DELAY); clearComposingText(); } }; setInputType(getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); setOnItemClickListener(null); setCustomSelectionActionModeCallback(this); mHandler = new Handler() { @Override public void handleMessage(final Message msg) { if (msg.what == DISMISS) { //((ListPopupWindow)msg.obj).dismiss(); return; } super.handleMessage(msg); } }; mTextWatcher = new RecipientTextWatcher(); addTextChangedListener(mTextWatcher); mGestureDetector = new GestureDetector(context, this); setOnEditorActionListener(this); }
From source file:com.entertailion.android.launcher.Dialogs.java
/** * Display a grid of all installed apps + virtual apps. Allow user to launch * apps./*from ww w . java 2 s . c om*/ * * @param context * @param applications */ public static void displayAllApps(final Launcher context, final ArrayList<ApplicationInfo> applications) { final Dialog dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.apps_grid); final GridView gridView = (GridView) dialog.findViewById(R.id.grid); gridView.setAdapter(new AllItemAdapter(context, getApplications(context, applications, false))); gridView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ItemInfo itemInfo = (ItemInfo) parent.getAdapter().getItem(position); itemInfo.invoke(context); context.showCover(false); dialog.dismiss(); if (itemInfo instanceof ApplicationInfo) { ApplicationInfo applicationInfo = (ApplicationInfo) itemInfo; RecentAppsTable.persistRecentApp(context, applicationInfo); } } }); gridView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> gridView, View view, int pos, long arg3) { ItemInfo itemInfo = (ItemInfo) gridView.getAdapter().getItem(pos); if (itemInfo instanceof ApplicationInfo) { Uri packageURI = Uri.parse("package:" + itemInfo.getIntent().getComponent().getPackageName()); Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI); context.startActivity(uninstallIntent); context.showCover(false); dialog.dismiss(); Analytics.logEvent(Analytics.UNINSTALL_APP); } return false; } }); gridView.setDrawingCacheEnabled(true); gridView.setOnKeyListener(onKeyListener); dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { context.showCover(false); } }); context.showCover(true); dialog.show(); Analytics.logEvent(Analytics.DIALOG_ALL_APPS); }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
public void promptPasswordForImport(final String fpath, final NotifyEvent ntfy_pswd) { // ??// w w w . jav a 2 s . co m final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.password_input_dlg); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.password_input_dlg_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.password_input_title_view); final TextView title = (TextView) dialog.findViewById(R.id.password_input_title); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); final TextView dlg_msg = (TextView) dialog.findViewById(R.id.password_input_msg); final CheckedTextView ctv_protect = (CheckedTextView) dialog.findViewById(R.id.password_input_ctv_protect); final Button btn_ok = (Button) dialog.findViewById(R.id.password_input_ok_btn); final Button btn_cancel = (Button) dialog.findViewById(R.id.password_input_cancel_btn); final EditText et_password = (EditText) dialog.findViewById(R.id.password_input_password); final EditText et_confirm = (EditText) dialog.findViewById(R.id.password_input_password_confirm); et_confirm.setVisibility(EditText.GONE); btn_ok.setText(mContext.getString(R.string.msgs_export_import_pswd_btn_ok)); ctv_protect.setVisibility(CheckedTextView.GONE); dlg_msg.setText(mContext.getString(R.string.msgs_export_import_pswd_password_required)); CommonDialog.setDlgBoxSizeCompact(dialog); btn_ok.setEnabled(false); et_password.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { if (arg0.length() > 0) btn_ok.setEnabled(true); else btn_ok.setEnabled(false); } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } @Override public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } }); //OK button btn_ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String passwd = et_password.getText().toString(); BufferedReader br; String pl; boolean pswd_invalid = true; try { br = new BufferedReader(new FileReader(fpath), 8192); pl = br.readLine(); if (pl != null) { String enc_str = ""; if (pl.startsWith(SMBSYNC_PROF_VER1 + SMBSYNC_PROF_ENC)) { enc_str = pl.replace(SMBSYNC_PROF_VER1 + SMBSYNC_PROF_ENC, ""); } if (!enc_str.equals("")) { CipherParms cp = EncryptUtil.initDecryptEnv(mGp.profileKeyPrefix + passwd); byte[] enc_array = Base64Compat.decode(enc_str, Base64Compat.NO_WRAP); String dec_str = EncryptUtil.decrypt(enc_array, cp); if (!SMBSYNC_PROF_ENC.equals(dec_str)) { dlg_msg.setText( mContext.getString(R.string.msgs_export_import_pswd_invalid_password)); } else { pswd_invalid = false; } } } br.close(); } catch (IOException e) { e.printStackTrace(); } if (!pswd_invalid) { dialog.dismiss(); ntfy_pswd.notifyToListener(true, new Object[] { passwd }); } } }); // CANCEL? btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); ntfy_pswd.notifyToListener(false, null); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); // dialog.setCancelable(false); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); dialog.show(); }