Refine search
AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Title"); // Set up the input final EditText input = new EditText(this); // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); builder.setView(input); // Set up the buttons builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { m_Text = input.getText().toString(); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.show();
EditText etEmojiEditText = new EditText(this); etEmojiEditText.setText("TYPE SOMETHING IN EMOJI"); String toServer = etEmojiEditText.getText(); String toServerUnicodeEncoded = StringEscapeUtils.escapeJava(toServer); String serverResponse = "SOME RESPONSE FROM SERVER WITH UNICODE CHARACTERS"; String fromServerUnicodeDecoded = StringEscapeUtils.unescapeJava(serverResponse);
final AlertDialog.Builder alert = new AlertDialog.Builder(this); final EditText input = new EditText(this); final EditText input1 = new EditText(this); lila1.addView(input); lila1.addView(input1); alert.setView(lila1); String value = input.getText().toString().trim(); Toast.makeText(getApplicationContext(), value, Toast.LENGTH_SHORT).show(); } });
int negativeButtonText, final TextSetListener onNegative, final DialogInterface.OnDismissListener onDismiss) { final EditText input = new EditText(activity); input.setSingleLine(); if (initialText != null) { input.setText(initialText); Selection.setSelection(input.getText(), initialText.length()); input.setImeActionLabel(activity.getResources().getString(positiveButtonText), KeyEvent.KEYCODE_ENTER); input.setOnEditorActionListener((v, actionId, event) -> { onPositive.onTextSet(input.getText().toString()); dialogHolder[0].dismiss(); return true; layout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); layout.setPadding(paddingTopAndSides, paddingTopAndSides, paddingTopAndSides, paddingBottom); layout.addView(input); .setPositiveButton(positiveButtonText, (d, whichButton) -> onPositive.onTextSet(input.getText().toString()));
AlertDialog.Builder builder = new AlertDialog.Builder(this); LinearLayout wrapper = new LinearLayout(this); WebView webView = new WebView(this); EditText keyboardHack = new EditText(this); keyboardHack.setVisibility(View.GONE); webView.loadUrl(url); wrapper.setOrientation(LinearLayout.VERTICAL); wrapper.addView(webView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); wrapper.addView(keyboardHack, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); builder.setView(wrapper); builder.create().show();
AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Title"); alert.setMessage("Message"); // Set an EditText view to get user input final EditText input = new EditText(this); alert.setView(input); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do something with value! } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show();
final EditText txtUrl = new EditText(this); // Set the default text to a link of the Queen txtUrl.setHint("http://www.librarising.com/astrology/celebs/images2/QR/queenelizabethii.jpg"); new AlertDialog.Builder(this) .setTitle("Moustachify Link") .setMessage("Paste in the link of an image to moustachify!") .setView(txtUrl) .setPositiveButton("Moustachify", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String url = txtUrl.getText().toString(); moustachify(null, url); } }) .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }) .show();
@Override public void createUI(Context context, LinearLayout layout) { mEditText = new EditText(mActivity); mEditText.setMinLines(3); mEditText.setText(mField.getText()); layout.addView(mEditText, LayoutParams.MATCH_PARENT); LinearLayout layoutTools = new LinearLayout(mActivity); layoutTools.setOrientation(LinearLayout.HORIZONTAL); layout.addView(layoutTools); LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1); createCloneButton(layoutTools, p); createClearButton(layoutTools, p); // search label TextView mSearchLabel = new TextView(mActivity); mSearchLabel.setText(R.string.multimedia_editor_text_field_editing_search_label); layout.addView(mSearchLabel); // search buttons LinearLayout layoutTools2 = new LinearLayout(mActivity); layoutTools2.setOrientation(LinearLayout.HORIZONTAL); layout.addView(layoutTools2); createTranslateButton(layoutTools2, p); createPronounceButton(layoutTools2, p); }
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final AlertDialog.Builder alert = new AlertDialog.Builder(this); final EditText input = new EditText(this); alert.setView(input); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString().trim(); Toast.makeText(getApplicationContext(), value, Toast.LENGTH_SHORT).show(); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); alert.show(); }
LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); layout.setGravity(Gravity.CENTER_HORIZONTAL); final EditText input = new EditText(this); input.setSingleLine(true); layout.setPadding(10, 0, 10, 0); input.setHint("Hint"); layout.addView(input); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setView(layout);
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); tv.setTextSize(20); EditText et = new EditText(this); etStr = et.getText().toString(); TextView tv1 = new TextView(this);
@Nullable @Override public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.notes_fragment, container, false); // Find the clear button and wire the click listener to call the clear notes updatable view.findViewById(R.id.clear).setOnClickListener(v -> notesStore.clearNotes()); // Find the add button and wire the click listener to show a dialog that in turn calls the add // note from text from the notes store when adding notes view.findViewById(R.id.add).setOnClickListener(v -> { final EditText editText = new EditText(v.getContext()); editText.setId(R.id.edit); new AlertDialog.Builder(v.getContext()) .setTitle(R.string.add_note) .setView(editText) .setPositiveButton(R.string.add, (d, i) -> { notesStore.insertNoteFromText(editText.getText().toString()); }) .create().show(); }); // Setup the recycler view using the repository adapter recyclerView = (RecyclerView) view.findViewById(R.id.result); recyclerView.setAdapter(adapter); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); final ImageView imageView = (ImageView) view.findViewById(R.id.background); updatable = () -> backgroundRepository.get().ifSucceededSendTo(imageView::setImageBitmap); return view; }
svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); etContent = new EditText(activity); int padding = (int) (DESIGN_LEFT_PADDING * ratio); etContent.setPadding(padding, padding, padding, padding); etContent.setText(sp.getText()); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); llContent.addView(etContent, lp); etContent.addTextChangedListener(this); lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth); lp.leftMargin = lp.rightMargin = lp.bottomMargin = lp.topMargin = padding; llContent.addView(rlThumb, lp);
public class MyActivity extends Activity { private String result; void showDialog() { AlertDialog.Builder b = new AlertDialog.Builder(this); b.setTitle("Please enter a password"); final EditText input = new EditText(this); b.setView(input); b.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { result = input.getText().toString(); } }); b.setNegativeButton("CANCEL", null); b.show(); } }
final AlertDialog.Builder alert = new AlertDialog.Builder(this); final LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); final EditText inputstreet = new EditText(this); final EditText inputstreetnumber = new EditText(this); layout.addView(inputstreet); layout.addView(inputstreetnumber); alert.setView(layout);
final AlertDialog.Builder alert = new AlertDialog.Builder(this); final EditText input = new EditText(this); alert.setView(input);
Builder builder = new Builder(this); final EditText input = new EditText(this); builder .setTitle(R.string.dialog_title_addsubject) .setMessage(R.string.dialog_addsubject) .setView(input) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String value = input.getText().toString(); if (input.getText().toString().trim().length() == 0) { Toast.makeText(Main.this, R.string.input_empty, Toast.LENGTH_SHORT).show(); } else { db.insertSubject(value); getData(); } InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(input.getWindowToken(), 0); } }) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(input.getWindowToken(), 0); } }); builder.show(); input.requestFocus(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); etContent = new EditText(activity); int padding = (int) (DESIGN_LEFT_PADDING * ratio); etContent.setPadding(padding, padding, padding, padding); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT); lp.weight = 1; llContent.addView(etContent, lp); etContent.addTextChangedListener(this); lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth); lp.rightMargin = lp.bottomMargin = lp.topMargin = padding; llContent.addView(rlThumb, lp);
final EditText textEdit = new EditText(this); AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Enter text"); alert.setView(textEdit); @Override public void onClick(DialogInterface dialog, int which) { String text = textEdit.getText().toString(); finish();