List of usage examples for android.widget EditText EditText
public EditText(Context context)
From source file:com.munger.passwordkeeper.alert.InputFragment.java
/** * grab references to all the alert components and setup event handlers. *///from www . j a v a2 s .c o m @Override public Dialog onCreateDialog(Bundle savedInstanceState) { inputView = new EditText(getActivity()); inputView.setHint(prompt); inputView.setSingleLine(); //submit on keyboard enter inputView.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER) { okay(); return true; } else return false; } }); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(inputView); builder.setMessage(message); //this is a blank handler, the real one is in the onStart method builder.setPositiveButton("Okay", null); builder.setNegativeButton("Cacnel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { listener.cancel(); } }); return builder.create(); }
From source file:com.cyanogenmod.eleven.menu.BasePlaylistDialog.java
/** * {@inheritDoc}/*from www . j a v a 2 s . c om*/ */ @Override public Dialog onCreateDialog(final Bundle savedInstanceState) { // Initialize the alert dialog mPlaylistDialog = new AlertDialog.Builder(getActivity()).create(); // Initialize the edit text mPlaylist = new EditText(getActivity()); // To show the "done" button on the soft keyboard mPlaylist.setSingleLine(true); // All caps mPlaylist.setInputType(mPlaylist.getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_CAP_WORDS); // Set the save button action mPlaylistDialog.setButton(Dialog.BUTTON_POSITIVE, getString(R.string.save), new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { onSaveClick(); MusicUtils.refresh(); dialog.dismiss(); } }); // Set the cancel button action mPlaylistDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(R.string.cancel), new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { MusicUtils.refresh(); dialog.dismiss(); } }); mPlaylist.post(new Runnable() { @Override public void run() { // Request focus to the edit text mPlaylist.requestFocus(); // Select the playlist name mPlaylist.selectAll(); }; }); initObjects(savedInstanceState); mPlaylistDialog.setTitle(mPrompt); mPlaylistDialog.setView(mPlaylist); mPlaylist.setText(mDefaultname); mPlaylist.setSelection(mDefaultname.length()); mPlaylist.addTextChangedListener(mTextWatcher); mPlaylistDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); mPlaylistDialog.show(); return mPlaylistDialog; }
From source file:com.boko.vimusic.menu.BasePlaylistDialog.java
/** * {@inheritDoc}//from w w w . j a v a 2 s . c o m */ @Override public Dialog onCreateDialog(final Bundle savedInstanceState) { // Initialize the alert dialog mPlaylistDialog = new AlertDialog.Builder(getActivity()).create(); // Initialize the edit text mPlaylist = new EditText(getActivity()); // To show the "done" button on the soft keyboard mPlaylist.setSingleLine(true); // All caps mPlaylist.setInputType(mPlaylist.getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_CAP_WORDS); // Set the save button action mPlaylistDialog.setButton(Dialog.BUTTON_POSITIVE, getString(R.string.save), new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { onSaveClick(); MusicUtils.refresh(getActivity()); dialog.dismiss(); } }); // Set the cancel button action mPlaylistDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(R.string.cancel), new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { closeKeyboard(); MusicUtils.refresh(getActivity()); dialog.dismiss(); } }); mPlaylist.post(new Runnable() { @Override public void run() { // Open up the soft keyboard openKeyboard(); // Request focus to the edit text mPlaylist.requestFocus(); // Select the playlist name mPlaylist.selectAll(); }; }); initObjects(savedInstanceState); mPlaylistDialog.setTitle(mPrompt); mPlaylistDialog.setView(mPlaylist); mPlaylist.setText(mDefaultname); mPlaylist.setSelection(mDefaultname.length()); mPlaylist.addTextChangedListener(mTextWatcher); mPlaylistDialog.show(); return mPlaylistDialog; }
From source file:com.andrew.apollo.menu.BasePlaylistDialog.java
/** * {@inheritDoc}// ww w . ja va 2 s .co m */ @Override public Dialog onCreateDialog(final Bundle savedInstanceState) { // Initialize the alert dialog mPlaylistDialog = new AlertDialog.Builder(getActivity()).create(); // Initialize the edit text mPlaylist = new EditText(getActivity()); // To show the "done" button on the soft keyboard mPlaylist.setSingleLine(true); // All caps mPlaylist.setInputType(mPlaylist.getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_CAP_WORDS); // Set the save button action mPlaylistDialog.setButton(Dialog.BUTTON_POSITIVE, getString(R.string.save), new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { onSaveClick(); MusicUtils.refresh(); dialog.dismiss(); } }); // Set the cancel button action mPlaylistDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(R.string.cancel), new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { closeKeyboard(); MusicUtils.refresh(); dialog.dismiss(); } }); mPlaylist.post(new Runnable() { @Override public void run() { // Open up the soft keyboard openKeyboard(); // Request focus to the edit text mPlaylist.requestFocus(); // Select the playlist name mPlaylist.selectAll(); }; }); initObjects(savedInstanceState); mPlaylistDialog.setTitle(mPrompt); mPlaylistDialog.setView(mPlaylist); mPlaylist.setText(mDefaultname); mPlaylist.setSelection(mDefaultname.length()); mPlaylist.addTextChangedListener(mTextWatcher); mPlaylistDialog.show(); return mPlaylistDialog; }
From source file:es.pentalo.apps.RBPiCameraControl.MainActivity.java
public void showAlertDialog(Boolean showAlways) { prefs = PreferenceManager.getDefaultSharedPreferences(this); String ipCam = prefs.getString(Constants.KEY_PREF_RBPI_IP, null); if (ipCam != null) Log.d(TAG, ipCam);//from w w w . j a v a 2 s .c om if (ipCam == null || showAlways) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); final EditText input = new EditText(this); if (ipCam != null) input.setText(ipCam); alertDialogBuilder.setView(input); alertDialogBuilder.setTitle(getString(R.string.dialog_title_rbpi_ip)); alertDialogBuilder.setMessage(getString(R.string.dialog_message_rbpi_ip)).setCancelable(false) .setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Editor edit = prefs.edit(); edit.putString(Constants.KEY_PREF_RBPI_IP, input.getText().toString()); edit.putString(Constants.KEY_PREF_RBPI_URL, "http://" + input.getText().toString() + "/"); edit.commit(); checkConnection(); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); MainActivity.this.finish(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); } else initApp(); }
From source file:company.test.Test.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); switch (id) { case R.id.add_item: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Add a task"); builder.setMessage("What do you want to do?"); final EditText inputField = new EditText(this); builder.setView(inputField);/*from w w w . j a v a2s.c o m*/ builder.setPositiveButton("Add", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { String task = inputField.getText().toString(); Log.d("MainActivity", task); SQLiteDatabase db = helper.getWritableDatabase(); ContentValues values = new ContentValues(); values.clear(); values.put(ItemContract.Columns.ITEM, task); db.insertWithOnConflict(ItemContract.TABLE, null, values, SQLiteDatabase.CONFLICT_IGNORE); activity.updateUI(); } }); builder.setNegativeButton("Cancel", null); builder.create().show(); return true; case R.id.action_settings: Log.d("MainActivity", "Settings"); return true; default: return false; } }
From source file:ch.jeda.platform.android.InputDialogFragment.java
@Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final AlertDialog.Builder builder = new AlertDialog.Builder(this.getActivity()); builder.setTitle(this.request.getTitle()); builder.setMessage(this.request.getMessage()); this.input = new EditText(this.getActivity()); // This is required in order to show soft keyboard when input is focused. this.input.setFocusableInTouchMode(true); this.input.setImeOptions(EditorInfo.IME_ACTION_DONE); this.input.setInputType(EditorInfo.TYPE_CLASS_TEXT); this.input.addTextChangedListener(this); final InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(this.input, InputMethodManager.SHOW_IMPLICIT); builder.setView(this.input); builder.setPositiveButton("OK", this); builder.setNegativeButton("Abbrechen", this); return builder.create(); }
From source file:com.cerema.cloud2.ui.dialog.CredentialsDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Create field for username mUsernameET = new EditText(getActivity()); mUsernameET.setHint(getActivity().getText(R.string.auth_username)); // Create field for password mPasswordET = new EditText(getActivity()); mPasswordET.setHint(getActivity().getText(R.string.auth_password)); mPasswordET.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); // Prepare LinearLayout for dialog LinearLayout ll = new LinearLayout(getActivity()); ll.setOrientation(LinearLayout.VERTICAL); ll.addView(mUsernameET);/*ww w. j a va2 s .co m*/ ll.addView(mPasswordET); ll.requestFocus(); setRetainInstance(true); Builder authDialog = new AlertDialog.Builder(getActivity()) .setTitle(getActivity().getText(R.string.saml_authentication_required_text)).setView(ll) .setCancelable(false).setPositiveButton(R.string.common_ok, this) .setNegativeButton(R.string.common_cancel, this); Dialog d = authDialog.create(); d.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE); return d; }
From source file:alexander.martinz.libs.materialpreferences.MaterialEditTextPreference.java
@Override public boolean init(Context context, AttributeSet attrs) { if (mInit) {//from w w w. j av a 2 s. c o m return false; } mInit = true; if (!super.init(context, attrs)) { return false; } if (mEditTextValue == null) { mEditTextValue = new EditText(context); mEditTextValue.setText(mDefaultValue); if (mPrefTextColor != -1) { if (isInEditMode()) { mEditTextValue.setTextColor(Color.parseColor("#009688")); } else { mEditTextValue.setTextColor(ContextCompat.getColor(context, mPrefTextColor)); } } if (mPrefTextSize != -1) { mEditTextValue.setTextSize(TypedValue.COMPLEX_UNIT_SP, mPrefTextSize); } mEditTextValue.setInputType(InputType.TYPE_NULL); mEditTextValue.setEllipsize(TextUtils.TruncateAt.END); mEditTextValue.setOnClickListener(this); addToWidgetFrame(mEditTextValue); } setOnClickListener(this); return true; }
From source file:com.nextgis.mobile.map.LocalGeoJsonLayer.java
protected static void showPropertiesDialog(final MapBase map, final boolean bCreate, String layerName, final Uri uri, final LocalGeoJsonLayer layer) { final LinearLayout linearLayout = new LinearLayout(map.getContext()); final EditText input = new EditText(map.getContext()); input.setText(layerName);//from w w w . j a v a2 s. co m final TextView stLayerName = new TextView(map.getContext()); stLayerName.setText(map.getContext().getString(R.string.layer_name) + ":"); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(stLayerName); linearLayout.addView(input); if (!bCreate) { //TODO: style for drawing } new AlertDialog.Builder(map.getContext()) .setTitle(bCreate ? R.string.input_layer_properties : R.string.change_layer_properties) // .setMessage(message) .setView(linearLayout).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { if (bCreate) { create(map, input.getText().toString(), uri); } else { layer.setName(input.getText().toString()); map.onLayerChanged(layer); } } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. Toast.makeText(map.getContext(), R.string.error_cancel_by_user, Toast.LENGTH_SHORT).show(); } }).show(); }