@Override public Dialog onCreateDialog(final Bundle savedInstanceState) { Activity activity = getActivity(); Bundle arguments = getArguments(); final AlertDialog dialog = createDialog(); dialog.setButton(BUTTON_NEGATIVE, activity.getString(R.string.cancel), this); dialog.setButton(BUTTON_NEUTRAL, activity.getString(R.string.clear), this); LayoutInflater inflater = activity.getLayoutInflater(); ListView view = (ListView) inflater.inflate(R.layout.dialog_list_view, null); view.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { onClick(dialog, position); } }); ArrayList<Milestone> choices = getChoices(); int selected = arguments.getInt(ARG_SELECTED_CHOICE); MilestoneListAdapter adapter = new MilestoneListAdapter( inflater, choices.toArray(new Milestone[choices.size()]), selected); view.setAdapter(adapter); if (selected >= 0) view.setSelection(selected); dialog.setView(view); return dialog; }
private void popdialogue() { final AlertDialog builder = new AlertDialog.Builder(EditPage.this).create(); LayoutInflater inflater = LayoutInflater.from(this); View selectView = inflater.inflate(R.layout.picture_dialog, (ViewGroup) findViewById(R.id.layout_root)); gridView = (GridView) selectView.findViewById(R.id.gridview); PictureAdapter adapter = new PictureAdapter(ImageUtil.imageMoodTitles, ImageUtil.imageMoodFiles, this); gridView.setAdapter(adapter); gridView.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { mMoodIndex = position; ImageButton mMoodButton = (ImageButton) findViewById(R.id.emotion_sticker); mMoodButton.setImageResource(ImageUtil.imageMoodFiles[position]); if (builder != null) builder.dismiss(); } }); builder.setCancelable(false); builder.setTitle(R.string.stringHowAboutYourMood); builder.setView(selectView); builder.setCancelable(true); builder.show(); }
public void showShareCommentDialog(Context context, final DialogFlowController controller) { final EditText text = new EditText(context); text.setMinLines(5); text.setGravity(Gravity.TOP); AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle("Share"); builder.setMessage("Enter a comment (Optional)"); builder.setPositiveButton( "OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { controller.onContinue(text.getText().toString()); } }); builder.setNegativeButton( "Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { controller.onCancel(); } }); AlertDialog dialog = builder.create(); dialog.setView(text); dialog.show(); }
public void requestPassword(final Bundle savedInstanceState) { mPasswordView = new EditText(this); mPasswordView.setInputType(EditorInfo.TYPE_TEXT_VARIATION_PASSWORD); mPasswordView.setTransformationMethod(new PasswordTransformationMethod()); AlertDialog alert = mAlertBuilder.create(); alert.setTitle(R.string.enter_password); alert.setView(mPasswordView); alert.setButton( AlertDialog.BUTTON_POSITIVE, getString(R.string.okay), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (core.authenticatePassword(mPasswordView.getText().toString())) { createUI(savedInstanceState); } else { requestPassword(savedInstanceState); } } }); alert.setButton( AlertDialog.BUTTON_NEGATIVE, getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }); alert.show(); }
public void show() { // TODO Auto-generated method stub alertDialog.setView( ((Activity) (context)).getLayoutInflater().inflate(R.layout.recharge_dialog, null)); alertDialog.show(); alertDialog.getWindow().setContentView(view); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); main = getLayoutInflater().inflate(R.layout.account, null); list = (TableLayout) main.findViewById(R.id.accounttable); tvbalance = (TextView) main.findViewById(R.id.accountbalance); setContentView(main); prompt = getLayoutInflater().inflate(R.layout.dialogaccount, null); accamount = (MyTextBox) prompt.findViewById(R.id.accountamount); accnumber = (MyTextBox) prompt.findViewById(R.id.accountnumber); accbank = (MyTextBox) prompt.findViewById(R.id.accountbank); accname = (MyTextBox) prompt.findViewById(R.id.accountholder); dialog = new AlertDialog.Builder(this) .setPositiveButton("Submit", null) .setNegativeButton("Cancel", null) .setMessage("Fill up the details below. Our customer service will contact you shortly") .setTitle("Request payment") .create(); dialog.setView(prompt); dialog.setOnShowListener(this); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setIcon(android.R.color.transparent); HashMap<String, Object> pars = new HashMap<String, Object>(); pars.put("loginkey", Shared.loginkey); request = SimpleHttp.request("list", Shared.url + "profile/getAccountHistory", pars, this); }
private void dialogie(String s) { if (s == null || s.length() == 0) return; AlertDialog ad = new AlertDialog.Builder(me).create(); ad.setCancelable(true); ad.setCanceledOnTouchOutside(true); ad.setTitle("Linkification view"); LinearLayout rl = new LinearLayout(me); rl.setBackgroundColor(Color.WHITE); rl.setPadding(scalemex(5), scalemex(25), scalemex(5), scalemex(25)); TextView tv; tv = new TextView(me); rl.addView(tv); tv.setBackgroundColor(Color.WHITE); tv.setTextColor(Color.BLACK); tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 19f); tv.setText(s); Linkify.addLinks(tv, Linkify.ALL); ScrollView ho = new ScrollView(me); ho.addView(rl); ad.setView(ho); ad.show(); }
@Override protected Dialog onCreateDialog(int id) { switch (id) { case PASSWORD_DIALOG: AlertDialog.Builder builder = new AlertDialog.Builder(this); final AlertDialog passwordDialog = builder.create(); passwordDialog.setTitle(getString(R.string.enter_admin_password)); final EditText input = new EditText(this); input.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); input.setTransformationMethod(PasswordTransformationMethod.getInstance()); passwordDialog.setView(input, 20, 10, 20, 10); passwordDialog.setButton( AlertDialog.BUTTON_POSITIVE, getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString(); String pw = mAdminPreferences.getString(AdminPreferencesActivity.KEY_ADMIN_PW, ""); if (pw.compareTo(value) == 0) { Intent i = new Intent(getApplicationContext(), AdminPreferencesActivity.class); startActivity(i); input.setText(""); passwordDialog.dismiss(); } else { Toast.makeText( MainMenuActivity.this, getString(R.string.admin_password_incorrect), Toast.LENGTH_SHORT) .show(); MyStatus.getInstance() .getActivityLogger() .logAction(this, "adminPasswordDialog", "PASSWORD_INCORRECT"); } } }); passwordDialog.setButton( AlertDialog.BUTTON_NEGATIVE, getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { MyStatus.getInstance() .getActivityLogger() .logAction(this, "adminPasswordDialog", "cancel"); input.setText(""); return; } }); passwordDialog .getWindow() .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); return passwordDialog; } return null; }
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); dialog = builder.create(); dialog.setView(getCustomView(), 0, 0, 0, 0); dialog.setCanceledOnTouchOutside(false); return dialog; }
private void showFile(final Metadata m) { final String fileType = m.containsNonNullValue(FileMetadata.FILE_TYPE) ? m.getValue(FileMetadata.FILE_TYPE) : FileMetadata.FILE_TYPE_OTHER; final String filePath = m.getValue(FileMetadata.FILE_PATH); if (fileType.startsWith(FileMetadata.FILE_TYPE_AUDIO)) { RecognizerApi.play( activity, m.getValue(FileMetadata.FILE_PATH), new PlaybackExceptionHandler() { @Override public void playbackFailed(String file) { showFromIntent(filePath, fileType); } }); } else if (fileType.startsWith(FileMetadata.FILE_TYPE_IMAGE)) { AlertDialog image = new AlertDialog.Builder(activity).create(); ImageView imageView = new ImageView(activity); imageView.setLayoutParams( new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); Bitmap bitmap = AndroidUtilities.readScaledBitmap(filePath); if (bitmap == null) { Toast.makeText(activity, R.string.file_err_memory, Toast.LENGTH_LONG).show(); return; } imageView.setImageBitmap(bitmap); image.setView(imageView); image.setButton( activity.getString(R.string.DLG_close), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface d, int which) { return; } }); image.show(); } else { String useType = fileType; if (fileType.equals(FileMetadata.FILE_TYPE_OTHER)) { String extension = AndroidUtilities.getFileExtension(filePath); MimeTypeMap map = MimeTypeMap.getSingleton(); String guessedType = map.getMimeTypeFromExtension(extension); if (!TextUtils.isEmpty(guessedType)) useType = guessedType; if (useType != guessedType) { m.setValue(FileMetadata.FILE_TYPE, useType); metadataService.save(m); } } showFromIntent(filePath, useType); } }
/** 第一次进入手机防盗界面 */ private void showFirstEntryDialog() { AlertDialog.Builder builder = new Builder(this); final AlertDialog d = builder.create(); d.setTitle("输入密码"); View view = inflater.inflate(R.layout.first_entry_dialog, null); final EditText first_pwd_et = (EditText) view.findViewById(R.id.first_password_et); final EditText second_pwd_et = (EditText) view.findViewById(R.id.second_password_et); // d.addContentView(view, new LayoutParams(90, 100)); d.setView(view); // 不允许用户通过 后退键 取消对话框 d.setCancelable(false); d.show(); Button confirm_bt = (Button) view.findViewById(R.id.lostProtectedConfirmbt); Button cancle_bt = (Button) view.findViewById(R.id.lostProtectedCanclebt); confirm_bt.setOnClickListener( new OnClickListener() { String endcodedpwd; public void onClick(View v) { // TODO Auto-generated method stub String first_pwd = first_pwd_et.getText().toString(); String second_pwd = second_pwd_et.getText().toString(); try { endcodedpwd = MD5Encoder.getMD5code(first_pwd); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } if ("".equals(first_pwd) || "".equals(second_pwd)) { Toast.makeText(getApplicationContext(), "密码不能为空", 1).show(); } else if (first_pwd.equals(second_pwd)) { Editor editer = sp.edit(); editer.putString("password", endcodedpwd); editer.commit(); d.dismiss(); // setContentView(R.layout.lostprotect); LoadMainUI(); } else { Toast.makeText(getApplicationContext(), "两次密码输入不一样", 1).show(); } } }); cancle_bt.setOnClickListener( new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub d.dismiss(); finish(); } }); }
public void addBlackNumber(View v) { AlertDialog.Builder builder = new Builder(CallMSNActivity.this); View view = View.inflate(CallMSNActivity.this, R.layout.dialog_add_blacknumber, null); editText = (EditText) view.findViewById(R.id.et_blacknumber); phoneBox = (CheckBox) view.findViewById(R.id.cb_phone); smsBox = (CheckBox) view.findViewById(R.id.cb_sms); oKButton = (Button) view.findViewById(R.id.ok); cancelButton = (Button) view.findViewById(R.id.cancel); alertDialog = builder.create(); alertDialog.setView(view, 0, 0, 0, 0); cancelButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub alertDialog.dismiss(); } }); oKButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub String numberString = editText.getText().toString().trim(); String modeString = null; if (TextUtils.isEmpty(numberString)) { Toast.makeText(CallMSNActivity.this, "²»ÄÜΪ¿Õ°¡£¬¸ç¸ç", 2).show(); return; } else if (phoneBox.isChecked() && !smsBox.isChecked()) { modeString = "1"; } else if (!phoneBox.isChecked() && smsBox.isChecked()) { modeString = "2"; } else if (phoneBox.isChecked() && smsBox.isChecked()) { modeString = "3"; } else { Toast.makeText(CallMSNActivity.this, "Ñ¡Ôñģʽ", 2).show(); return; } blackNumberchange.blackNumberIncrease(numberString, modeString); BlackNumberInfo info = new BlackNumberInfo(); info.setNumber(numberString); info.setMode(modeString); blackNumberInfos.add(info); adapter.notifyDataSetChanged(); alertDialog.dismiss(); } }); alertDialog.show(); }
/** * @param context The aplication context. * @param resTitle Thew resoure string of the title. * @param resMessage The resource string of the message. Could be HTML. * @return Instance of a alert dialog with title and meesage. */ public static AlertDialog create(Context context, int resTitle, int resMessage) { TextView message = new TextView(context); message.setText(Html.fromHtml(context.getString(resMessage))); message.setTextColor(Color.WHITE); message.setTextSize(context.getResources().getDimension(R.dimen.text_small)); message.setPadding(16, 16, 16, 16); message.setClickable(true); message.setMovementMethod(LinkMovementMethod.getInstance()); AlertDialog alertDialog = new AlertDialog.Builder(context).create(); alertDialog.setTitle(resTitle); alertDialog.setView(message); return alertDialog; }
public void EditDialog() { LayoutInflater factory = LayoutInflater.from(this); final View FileDialogView = factory.inflate(R.layout.filedialog, null); EditText myEditText = (EditText) FileDialogView.findViewById(R.id.filename); final AlertDialog FileDialog = new AlertDialog.Builder(this).create(); FileDialog.setView(FileDialogView); FileDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); FileDialogView.findViewById(R.id.yes) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { fileName = ((TextView) FileDialogView.findViewById(R.id.filename)).getText().toString() + ".mp3"; myAudioRecorder.setOutputFile( Environment.getExternalStorageDirectory().getAbsolutePath() + "/VoiceRecorder/" + ((TextView) FileDialogView.findViewById(R.id.filename)) .getText() .toString() + ".mp3"); try { myAudioRecorder.prepare(); } catch (Exception e) { e.printStackTrace(); } myAudioRecorder.start(); chronometer.setBase(SystemClock.elapsedRealtime()); chronometer.start(); recording = true; // Start plotting chart new ChartTask().execute(); FileDialog.dismiss(); } }); FileDialogView.findViewById(R.id.no) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { FileDialog.dismiss(); } }); FileDialog.show(); }
/** 设置密码后进入手机防盗界面 */ private void showNormalEntryDialog() { // TODO Auto-generated method stub AlertDialog.Builder builder = new Builder(this); final AlertDialog d = builder.create(); View view = inflater.inflate(R.layout.normal_entry_dialog, null); // 不允许用户通过 后退键 取消对话框 d.setCancelable(false); d.setTitle("请输入密码 "); // RelativeLayout.LayoutParams // FrameLayout.LayoutParams d.setView(view); d.show(); final EditText normal_et = (EditText) view.findViewById(R.id.normal_password_et); Button confirm_bt = (Button) view.findViewById(R.id.secondConfirmbt); Button cancle_bt = (Button) view.findViewById(R.id.secondCanclebt); confirm_bt.setOnClickListener( new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub String password = normal_et.getText().toString(); String endcodepwd = null; try { endcodepwd = MD5Encoder.getMD5code(password); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } String realpwd = sp.getString("password", null); if (endcodepwd != null && realpwd != null && endcodepwd.equals(realpwd)) { Logger.i(TAG, "密码正确,进入lostprotectedactivity"); d.dismiss(); // setContentView(R.layout.lostprotect); LoadMainUI(); } else { Toast.makeText(getApplicationContext(), "密码不正确", 1).show(); } } }); cancle_bt.setOnClickListener( new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub d.dismiss(); finish(); } }); }
@Override public void onClick(View view) { LayoutInflater factory = (LayoutInflater) PersonalCVWorkInputActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View myView = factory.inflate(R.layout.dialog_select_year, null); AlertDialog.Builder builder = new AlertDialog.Builder(context); dialog = builder.create(); ((AlertDialog) dialog).setView(myView); dialog.setCancelable(true); dialog.setCanceledOnTouchOutside(true); dialog.show(); setWindow(540, 600); initYearSelectView(myView); }
private AlertDialog createAboutDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setPositiveButton( jr_dialog_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); AlertDialog retval = builder.create(); View l = retval.getWindow().getLayoutInflater().inflate(R.layout.jr_about_dialog, null); retval.setView(l); return retval; }
@Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { pos = arg2; String names[] = {"Naam wijzigen", "Prijzen aanpassen", "Verwijderen", "Nieuw tarief"}; alertDialog = new AlertDialog.Builder(this).create(); LayoutInflater inflater = getLayoutInflater(); View convertView = (View) inflater.inflate(R.layout.custom, null); alertDialog.setView(convertView); alertDialog.setTitle("Wat wil je doen?"); ListView listview = (ListView) convertView.findViewById(R.id.listView1); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, names); listview.setAdapter(adapter); listview.setOnItemClickListener(this); alertDialog.show(); return false; }
public void dialogLoginPassword() { AlertDialog.Builder builder = new Builder(HomeActivity.this); final AlertDialog dialog = builder.create(); dialog.setCanceledOnTouchOutside(false); // 点击屏幕其他地方 不让弹窗消失 View view = View.inflate(HomeActivity.this, R.layout.activity_login_password, null); dialog.setView(view); // 点击取消 Button btCancel = (Button) view.findViewById(R.id.bt_cancel); btCancel.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); // 点击确定 验证密码 final EditText edPass = (EditText) view.findViewById(R.id.et_password); Button btConfirm = (Button) view.findViewById(R.id.bt_confirm); btConfirm.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { String pass = edPass.getText().toString(); if (TextUtils.isEmpty(pass)) { Toast.makeText(HomeActivity.this, "密码不能为空或空格", Toast.LENGTH_SHORT).show(); } else { SharedPreferences mPref = getSharedPreferences("config", MODE_PRIVATE); String strPass = mPref.getString("password", ""); if (pass.equals(strPass)) { dialog.dismiss(); startActivity(new Intent(HomeActivity.this, LostFindActivity.class)); } else { Toast.makeText(HomeActivity.this, "密码错误", Toast.LENGTH_SHORT).show(); } } } }); dialog.show(); }
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setPositiveButton(getString(R.string.ok), this); builder.setNegativeButton(getString(R.string.cancel), this); builder.setTitle(getString(R.string.choose_seconds_delay)); AlertDialog dialog = builder.create(); View v = LayoutInflater.from(getActivity()).inflate(R.layout.delay_picker_fragment_layout, null); dialog.setView(v); mNumberPicker = (NumberPicker) v.findViewById(R.id.number_picker); mNumberPicker.setMinValue(1); mNumberPicker.setMaxValue(60); lastChosenDelay = getArguments().getInt(DEF_VALUE_TAG); if (lastChosenDelay == -1) { lastChosenDelay = 3; } mNumberPicker.setValue(lastChosenDelay); return dialog; }
@Override protected void onPostExecute(Void result) { if (progressDialog != null) { progressDialog.cancel(); } if (!error) { restaurant.setCompleteDataLoaded(Boolean.TRUE); } dialog = new AlertDialog.Builder(activity).create(); dialog.setInverseBackgroundForced(true); View view = createAndFillDataMovementLayout(restaurant, position); dialog.setView(view); dialog.show(); dialog.setOnDismissListener( new DialogInterface.OnDismissListener() { public void onDismiss(DialogInterface dialog) { dialog.cancel(); } }); }
public static void showDisclaimer(Activity context) { DialogHelper.context = context; if (DialogHelper.disclaimerAccepted) return; LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View layout = inflater.inflate(R.layout.disclaimer, (ViewGroup) context.findViewById(R.id.layout_root)); AlertDialog al = new AlertDialog(context) { @Override public boolean onSearchRequested() { return false; } }; al.setView(layout); al.setButton( "OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { CheckBox cb = (CheckBox) layout.findViewById(R.id.lic_ack); if (!cb.isChecked()) { Toast t = Toast.makeText( DialogHelper.context, DialogHelper.context.getString(R.string.accept_text), Toast.LENGTH_SHORT); t.show(); DialogHelper.showDisclaimer(DialogHelper.context); } else { disclaimerAccepted = true; } } }); al.setCancelable(false); al.show(); }
/** * Display extra help, triggered by user request. * * @param prompt */ private void fireHelpText(FormEntryPrompt prompt) { if (!prompt.hasHelp()) { return; } // Depending on ODK setting, help may be displayed either as // a dialog or inline, underneath the question text if (!PreferenceManager.getDefaultSharedPreferences(this.getContext().getApplicationContext()) .getBoolean(PreferencesActivity.KEY_HELP_MODE_TRAY, false)) { AlertDialog mAlertDialog = new AlertDialog.Builder(this.getContext()).create(); mAlertDialog.setIcon(android.R.drawable.ic_dialog_info); mAlertDialog.setTitle(""); ScrollView scrollView = new ScrollView(this.getContext()); scrollView.addView(createHelpLayout(prompt)); mAlertDialog.setView(scrollView); DialogInterface.OnClickListener errorListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int i) { switch (i) { case DialogInterface.BUTTON1: dialog.cancel(); break; } } }; mAlertDialog.setCancelable(true); mAlertDialog.setButton( StringUtils.getStringRobust(this.getContext(), R.string.ok), errorListener); mAlertDialog.show(); } else { if (helpPlaceholder.getVisibility() == View.GONE) { expand(helpPlaceholder); } else { collapse(helpPlaceholder); } } }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case 0: final EditText input = new EditText(this); AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle("SMS"); alertDialog.setMessage("Отправляемое сообщение:"); alertDialog.setView(input, 10, 0, 10, 0); // 10 spacing, left and right alertDialog.setButton( DialogInterface.BUTTON_NEGATIVE, "Отправить", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Conf.msg.add( new listMsg("-1", input.getText().toString(), Conf.getUnixTime(), false)); toastText("Сообщение отправлено..."); } }); alertDialog.show(); input.requestFocus(); InputMethodManager imm = (InputMethodManager) this.getSystemService(Service.INPUT_METHOD_SERVICE); imm.showSoftInput(input, 0); return true; case 1: if (point != null) { Conf.codeOld = this.point.code; Conf.codeNew = "-1"; Intent intent = new Intent(ActivityMap.this, ActivityBarcode.class); startActivity(intent); } return true; default: return super.onOptionsItemSelected(item); } }
/** 弹出设置密码界面,并设置密码 */ private void showRegistDialog() { View v = View.inflate(HomeActivity.this, R.layout.safe_regist_dialog, null); final EditText mPassword = (EditText) v.findViewById(R.id.et_password); final EditText mConfirmPw = (EditText) v.findViewById(R.id.et_password_confirm); Button mBt_ok = (Button) v.findViewById(R.id.bt_ok); Button mBt_cancel = (Button) v.findViewById(R.id.bt_cancel); AlertDialog.Builder builder = new AlertDialog.Builder(HomeActivity.this); setPasswordDialog = builder.create(); setPasswordDialog.setView(v); setPasswordDialog.show(); mBt_ok.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { final String password = mPassword.getText().toString(); final String confirmPW = mConfirmPw.getText().toString(); if (!TextUtils.isEmpty(password) && !TextUtils.isEmpty(confirmPW)) { if (password.equals(confirmPW)) { mPref.edit().putString("password", MD5Utils.encode(password)).commit(); setPasswordDialog.dismiss(); startActivity(new Intent(HomeActivity.this, LostFindActivity.class)); } else { Toast.makeText(HomeActivity.this, "账户名和密码不一致", Toast.LENGTH_LONG).show(); } } else { Toast.makeText(HomeActivity.this, "密码不能为空", Toast.LENGTH_LONG).show(); } } }); mBt_cancel.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { setPasswordDialog.dismiss(); } }); }
public void showUpdateAlertDialog() { databaseHandler = new DataBaseHandler(getActivity()); final TextView input = new TextView(getActivity()); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity()); alertDialogBuilder.setTitle("Update Info"); alertDialogBuilder .setCancelable(false) .setPositiveButton( "Ok", new DialogInterface.OnClickListener() { @SuppressLint("DefaultLocale") public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }) .setNegativeButton( "Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); // create alert dialog AlertDialog alertDialog = alertDialogBuilder.create(); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); input.setText("Are you sure?"); input.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL); input.setTextSize(20); input.setLayoutParams(lp); alertDialog.setView(input); alertDialog.show(); }
public static void DialogLookBigImg(Activity mActivity, FinalBitmap finalBitmap, String url) { LayoutInflater inflater = LayoutInflater.from(mActivity.getApplicationContext()); View imgEntryView = inflater.inflate(R.layout.dialog_look_big_img, null); final AlertDialog dialog = new AlertDialog.Builder(mActivity).create(); ImageView img = (ImageView) imgEntryView.findViewById(R.id.look_big_img); if (!TextUtils.isEmpty(url)) { finalBitmap.display(img, GlobalUtil.REMOTE_HOST + url); } else { dialog.dismiss(); } dialog.setView(imgEntryView); dialog.setCancelable(true); dialog.setCanceledOnTouchOutside(true); dialog.show(); img.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { dialog.cancel(); } }); }
// Metodo que describe una ventana de dialogo para establecer parametros de filtrado para el // HeatMap. public void abrirDialogoHeatMap() { // Se toman los elementos de un layout (comboheatmap.xml) que contiene un EditText para la // distancia de separacion entre puntos a filtrar // Y tres botones, uno para filtrar la busqueda de los lugares frecuentes (hora inicial, final y // fecha). AlertDialog ventana = new AlertDialog.Builder(this).create(); ventana.setTitle("Seleccionar valores"); LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.comboheatmap, null); final Button boton1 = (Button) layout.findViewById(R.id.HoraInicial); final Button boton2 = (Button) layout.findViewById(R.id.HoraFinal); final Button boton3 = (Button) layout.findViewById(R.id.Fecha); final EditText distancia = (EditText) layout.findViewById(R.id.cajaDistancia); // Se establece que hacer para el boton "Hora inicial". // Se abre una nueva ventana de dialogo para mostrar un TimePicker y seleccionar la hora // inicial. boton1.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { seleccion = 1; abrirDialogoTiempo(); } }); // Se establece que hacer para el boton "Hora final". // Se abre una nueva ventana de dialogo para mostrar un TimePicker y seleccionar la hora final. boton2.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { seleccion = 0; abrirDialogoTiempo(); } }); // Se establece que hacer para el boton "Fecha". // Se abre una nueva ventana de dialogo para mostrar un DatePicker y seleccionar la fecha. boton3.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { abrirDialogoFecha(); } }); // Se crea un boton propio de la ventana de Dialogo actual con el texto "Aceptar" para en base a // los parametros // establecidos, comenzar la busqueda y se pinten los puntos del heatmap. // Notese que los puntos se obtienen de la base de datos tomando en cuenta el usuario // seleccionado, la hora, fecha y distancia de separacion entre puntos. // Los cuales fueron tomados previamente gracias a lo establecido en los metodos // abrirDialogoTiempo y abrirDialogoFecha. ventana.setButton( "Aceptar", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int a) { try { // Se guarda la distancia de separacion y se despliega distanciaSeparacion = Double.parseDouble(distancia.getText().toString()); Toast.makeText( getBaseContext(), "Distancia: " + distanciaSeparacion, Toast.LENGTH_SHORT) .show(); } catch (Exception e) { distanciaSeparacion = 0; } trazarHeatMap(); } }); // Se toma una vista para la ventana de dialogo y se muestra. ventana.setView(layout); ventana.show(); }
// Metodo que describe una ventana de dialogo para establecer parametros de filtrado. public void abrirVentanaDialogo() { // Se toman los elementos de un layout (combo.xml) que contiene un objeto del tipo Spinner // (similar a un combo box) // Y tres botones, uno para filtrar la busqueda de la ruta (hora inicial, final y fecha). AlertDialog ventana = new AlertDialog.Builder(this).create(); ventana.setTitle("Seleccionar valores"); LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.combo, null); final Spinner spinnerUsuario = (Spinner) layout.findViewById(R.id.miSpinner); final Button boton1 = (Button) layout.findViewById(R.id.HoraInicial); final Button boton2 = (Button) layout.findViewById(R.id.HoraFinal); final Button boton3 = (Button) layout.findViewById(R.id.Fecha); // De la base de datos se toman todos los usuarios y se introducen en el Spinner. SimpleCursorAdapter sca = auxiliarBD.encontrarUsuarios(this); spinnerUsuario.setAdapter(sca); // Se establece que hacer en caso de haber seleccionado un Usuario especifico. Se guarda en una // variable global. spinnerUsuario.setOnItemSelectedListener( new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { Cursor c = (Cursor) parent.getItemAtPosition(pos); usuarioSeleccionado = c.getString(c.getColumnIndexOrThrow("usr_nombre")); } @Override public void onNothingSelected(AdapterView<?> parent) {} }); // Se establece que hacer para el boton "Hora inicial". // Se abre una nueva ventana de dialogo para mostrar un TimePicker y seleccionar la hora // inicial. boton1.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { seleccion = 1; abrirDialogoTiempo(); } }); // Se establece que hacer para el boton "Hora final". // Se abre una nueva ventana de dialogo para mostrar un TimePicker y seleccionar la hora final. boton2.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { seleccion = 0; abrirDialogoTiempo(); } }); // Se establece que hacer para el boton "Fecha". // Se abre una nueva ventana de dialogo para mostrar un DatePicker y seleccionar la fecha. boton3.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { abrirDialogoFecha(); } }); // Se crea un boton propio de la ventana de Dialogo actual con el texto "Aceptar" para en base a // los parametros // establecidos, comenzar la busqueda y calcular la distancia y velocidad promedio. // Notese que los puntos se obtienen de la base de datos tomando en cuenta el usuario // seleccionado, la hora y fecha. // Los cuales fueron tomados previamente gracias a lo establecido en los metodos // abrirDialogoTiempo y abrirDialogoFecha. ventana.setButton( "Aceptar", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int a) { // Se despliega el usuario seleccionado, se crea el objeto RutaOverlay y se adhiere al // mapa la ruta graficamente. // RutaOverlay calcula la distancia total y velocidad promedio y se despliegan cuando se // da "Tap". Toast.makeText(getBaseContext(), "Usuario: " + usuarioSeleccionado, Toast.LENGTH_SHORT) .show(); overlayRuta = new RutaOverlay( auxiliarBD, mapview, usuarioSeleccionado, horaInicial, horaFinal, fecha); mapview.getOverlays().add(overlayRuta); } }); // Se toma una vista para la ventana de dialogo y se muestra. ventana.setView(layout); ventana.show(); }
/** * Create an AmbilWarnaDialog. * * @param context activity context * @param color current color * @param supportsAlpha whether alpha/transparency controls are enabled * @param listener an OnAmbilWarnaListener, allowing you to get back error or OK */ public AmbilWarnaDialog( final Context context, int color, boolean supportsAlpha, OnAmbilWarnaListener listener) { this.supportsAlpha = supportsAlpha; this.listener = listener; if (!supportsAlpha) { // remove alpha if not supported color = color | 0xff000000; } Color.colorToHSV(color, currentColorHsv); alpha = Color.alpha(color); final View view = LayoutInflater.from(context).inflate(R.layout.ambilwarna_dialog, null); viewHue = view.findViewById(R.id.ambilwarna_viewHue); viewSatVal = (AmbilWarnaSquare) view.findViewById(R.id.ambilwarna_viewSatBri); viewCursor = (ImageView) view.findViewById(R.id.ambilwarna_cursor); viewOldColor = view.findViewById(R.id.ambilwarna_oldColor); viewNewColor = view.findViewById(R.id.ambilwarna_newColor); viewTarget = (ImageView) view.findViewById(R.id.ambilwarna_target); viewContainer = (ViewGroup) view.findViewById(R.id.ambilwarna_viewContainer); viewAlphaOverlay = view.findViewById(R.id.ambilwarna_overlay); viewAlphaCursor = (ImageView) view.findViewById(R.id.ambilwarna_alphaCursor); viewAlphaCheckered = (ImageView) view.findViewById(R.id.ambilwarna_alphaCheckered); { // hide/show alpha viewAlphaOverlay.setVisibility(supportsAlpha ? View.VISIBLE : View.GONE); viewAlphaCursor.setVisibility(supportsAlpha ? View.VISIBLE : View.GONE); viewAlphaCheckered.setVisibility(supportsAlpha ? View.VISIBLE : View.GONE); } viewSatVal.setHue(getHue()); viewOldColor.setBackgroundColor(color); viewNewColor.setBackgroundColor(color); viewHue.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_MOVE || event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_UP) { float y = event.getY(); if (y < 0.f) y = 0.f; if (y > viewHue.getMeasuredHeight()) { y = viewHue.getMeasuredHeight() - 0.001f; // to avoid jumping the cursor from bottom to top. } float hue = 360.f - 360.f / viewHue.getMeasuredHeight() * y; if (hue == 360.f) hue = 0.f; setHue(hue); // update view viewSatVal.setHue(getHue()); moveCursor(); viewNewColor.setBackgroundColor(getColor()); updateAlphaView(); return true; } return false; } }); if (supportsAlpha) viewAlphaCheckered.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if ((event.getAction() == MotionEvent.ACTION_MOVE) || (event.getAction() == MotionEvent.ACTION_DOWN) || (event.getAction() == MotionEvent.ACTION_UP)) { float y = event.getY(); if (y < 0.f) { y = 0.f; } if (y > viewAlphaCheckered.getMeasuredHeight()) { y = viewAlphaCheckered.getMeasuredHeight() - 0.001f; // to avoid jumping the cursor from bottom to top. } final int a = Math.round(255.f - ((255.f / viewAlphaCheckered.getMeasuredHeight()) * y)); AmbilWarnaDialog.this.setAlpha(a); // update view moveAlphaCursor(); int col = AmbilWarnaDialog.this.getColor(); int c = a << 24 | col & 0x00ffffff; viewNewColor.setBackgroundColor(c); return true; } return false; } }); viewSatVal.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_MOVE || event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_UP) { float x = event.getX(); // touch event are in dp units. float y = event.getY(); if (x < 0.f) x = 0.f; if (x > viewSatVal.getMeasuredWidth()) x = viewSatVal.getMeasuredWidth(); if (y < 0.f) y = 0.f; if (y > viewSatVal.getMeasuredHeight()) y = viewSatVal.getMeasuredHeight(); setSat(1.f / viewSatVal.getMeasuredWidth() * x); setVal(1.f - (1.f / viewSatVal.getMeasuredHeight() * y)); // update view moveTarget(); viewNewColor.setBackgroundColor(getColor()); return true; } return false; } }); dialog = new AlertDialog.Builder(context) .setPositiveButton( android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (AmbilWarnaDialog.this.listener != null) { AmbilWarnaDialog.this.listener.onOk(AmbilWarnaDialog.this, getColor()); } } }) .setNegativeButton( android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (AmbilWarnaDialog.this.listener != null) { AmbilWarnaDialog.this.listener.onCancel(AmbilWarnaDialog.this); } } }) .setOnCancelListener( new OnCancelListener() { // if back button is used, call back our listener. @Override public void onCancel(DialogInterface paramDialogInterface) { if (AmbilWarnaDialog.this.listener != null) { AmbilWarnaDialog.this.listener.onCancel(AmbilWarnaDialog.this); } } }) .create(); // kill all padding from the dialog window dialog.setView(view, 0, 0, 0, 0); // move cursor & target on first draw ViewTreeObserver vto = view.getViewTreeObserver(); vto.addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { moveCursor(); if (AmbilWarnaDialog.this.supportsAlpha) moveAlphaCursor(); moveTarget(); if (AmbilWarnaDialog.this.supportsAlpha) updateAlphaView(); view.getViewTreeObserver().removeGlobalOnLayoutListener(this); } }); }