private void showUserHashDialog() { String userHash = NavigineApp.Settings.getString("user_hash", ""); LayoutInflater inflater = getLayoutInflater(); View view = inflater.inflate(R.layout.user_hash_dialog, null); _userEdit = (EditText) view.findViewById(R.id.user_hash_edit); _userEdit.setText(userHash); _userEdit.setTypeface(Typeface.MONOSPACE); // _userEdit.addTextChangedListener(new TextWatcher() // { // public void afterTextChanged(Editable s) { } // public void beforeTextChanged(CharSequence s, int start, int count, int after) { } // public void onTextChanged(CharSequence s, int start, int before, int count) // { // String text = _userEdit.getText().toString(); // int length = _userEdit.getText().length(); // // if (text.endsWith("-")) // return; // // if (count <= before) // return; // // if (length == 4 || length == 9 || length == 14) // { // _userEdit.setText((text + "-")); // _userEdit.setSelection(length + 1); // } // } // }); AlertDialog.Builder alertBuilder = new AlertDialog.Builder(mContext); alertBuilder.setView(view); alertBuilder.setTitle("Enter user ID"); alertBuilder.setNegativeButton( getString(R.string.cancel_button), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dlg, int id) {} }); alertBuilder.setPositiveButton( getString(R.string.ok_button), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dlg, int id) { String userHash = _userEdit.getText().toString(); SharedPreferences.Editor editor = NavigineApp.Settings.edit(); editor.putString("user_hash", userHash); editor.commit(); NavigineApp.applySettings(); refreshMapList(); } }); AlertDialog dialog = alertBuilder.create(); dialog.setCanceledOnTouchOutside(false); dialog.show(); }
public void debug(String message) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); alertDialog.setNegativeButton( "Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); alertDialog.setMessage(message); AlertDialog balertDialog = alertDialog.create(); balertDialog.show(); }
private void doRetryableAlert(Exception e, String msg) { AlertDialog.Builder dialog = new AlertDialog.Builder(SelectAccount.this); dialog.setTitle(msg); String dispMsg = msg + "\n\n" + e.getMessage(); dialog.setMessage(dispMsg); dialog.setPositiveButton( "Retry", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { requestAccountList(); } }); dialog.setNegativeButton("Cancel", emptyClickListener); AlertDialog dlg = dialog.create(); dlg.show(); }
private void selectItem(int index) { _info = mInfoList.get(index); if (!(new File(_info.archiveFile)).exists()) { String text = String.format( Locale.ENGLISH, "Location '%s' cannot be selected!\n" + "Please, download location first!", _info.title); Toast.makeText(mContext, text, Toast.LENGTH_LONG).show(); return; } AlertDialog.Builder alertBuilder = new AlertDialog.Builder(mContext); alertBuilder.setTitle(String.format(Locale.ENGLISH, "Location '%s'", _info.title)); alertBuilder.setNegativeButton( "Delete location", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dlg, int id) { deleteLocation(_info); } }); alertBuilder.setPositiveButton( "Select location", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dlg, int id) { selectLocation(_info); } }); AlertDialog dialog = alertBuilder.create(); dialog.setCanceledOnTouchOutside(false); dialog.show(); }
@Override public void onClick(View view) { if (view.getId() == R.id.draw_btn) { if (!drawView.getErase()) { final Dialog brushDialog = new Dialog(this); brushDialog.setTitle("Brush size:"); brushDialog.setContentView(R.layout.brush_chooser); ImageButton smallBtn = (ImageButton) brushDialog.findViewById(R.id.small_brush); smallBtn.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { drawView.setBrushSize(smallBrush); drawView.setLastBrushSize(smallBrush); brushDialog.dismiss(); } }); ImageButton mediumBtn = (ImageButton) brushDialog.findViewById(R.id.medium_brush); mediumBtn.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { drawView.setBrushSize(mediumBrush); drawView.setLastBrushSize(mediumBrush); brushDialog.dismiss(); } }); ImageButton largeBtn = (ImageButton) brushDialog.findViewById(R.id.large_brush); largeBtn.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { drawView.setBrushSize(largeBrush); drawView.setLastBrushSize(largeBrush); brushDialog.dismiss(); } }); brushDialog.show(); } drawView.setErase(false); } else if (view.getId() == R.id.erase_btn) { if (drawView.getErase()) { final Dialog brushDialog = new Dialog(this); brushDialog.setTitle("Eraser size:"); brushDialog.setContentView(R.layout.brush_chooser); ImageButton smallBtn = (ImageButton) brushDialog.findViewById(R.id.small_brush); smallBtn.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { drawView.setBrushSize(smallBrush); brushDialog.dismiss(); } }); ImageButton mediumBtn = (ImageButton) brushDialog.findViewById(R.id.medium_brush); mediumBtn.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { drawView.setBrushSize(mediumBrush); brushDialog.dismiss(); } }); ImageButton largeBtn = (ImageButton) brushDialog.findViewById(R.id.large_brush); largeBtn.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { drawView.setBrushSize(largeBrush); brushDialog.dismiss(); } }); brushDialog.show(); } drawView.setErase(true); } else if (view.getId() == R.id.new_btn) { AlertDialog.Builder newDialog = new AlertDialog.Builder(this); newDialog.setTitle("New equation"); newDialog.setMessage("Start new equation?"); newDialog.setPositiveButton( "Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { drawView.startNew(); dialog.dismiss(); } }); newDialog.setNegativeButton( "Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); newDialog.show(); } else if (view.getId() == R.id.equals_btn) { // save drawing } }