List of usage examples for android.widget EditText getText
@Override
public Editable getText()
From source file:eu.operando.proxy.filters.domain.DomainFiltersActivity.java
@OnClick(R.id.add_filter) public void addFilter() { if (viewSelected == 0) { //User Filter View dialogView = getLayoutInflater().inflate(R.layout.user_domain_filter_dialog, null); final EditText input = (EditText) dialogView.findViewById(R.id.filter_content); final CheckBox isWildcard = (CheckBox) dialogView.findViewById(R.id.is_wildcard); AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle("New DomainFilter") .setView(dialogView)//from www. j a v a 2 s.c om .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { DomainFilter domainFilter = new DomainFilter(); domainFilter.setContent(input.getText().toString().toLowerCase()); domainFilter.setSource(null); domainFilter.setIsWildcard(isWildcard.isChecked()); db.createDomainFilter(domainFilter); updateFiltersList(); userDomainFiltersAdapter.notifyItemInserted(userFilters.size() - 1); recyclerView.scrollToPosition(userFilters.size() - 1); } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); final AlertDialog dialog = builder.create(); input.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (Patterns.DOMAIN_NAME.matcher(s).matches()) { dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true); } else dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); } }); dialog.show(); } else { //Imported filter list final EditText input = new EditText(this); input.setSingleLine(true); input.setHint("Enter URL"); new AlertDialog.Builder(this).setTitle("Import filters from remote file (hosts file format)") .setView(input).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { final String importUrl = input.getText().toString(); importExternalFilters(importUrl); } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }).show(); } }
From source file:org.sirimangalo.meditationplus.ActivityMain.java
@Override public void onClick(View view) { int id = view.getId(); ArrayList<NameValuePair> nvp = new ArrayList<NameValuePair>(); switch (id) { case R.id.chat_send: smiliesShell.setVisibility(View.GONE); EditText message = (EditText) findViewById(R.id.chat_text); String messageT = message.getText().toString(); if (messageT.length() == 0) { Toast.makeText(this, R.string.no_message, Toast.LENGTH_SHORT).show(); return; }//from ww w. j a va 2s . c o m if (messageT.length() > 140) { Toast.makeText(this, R.string.message_too_long, Toast.LENGTH_SHORT).show(); return; } nvp.add(new BasicNameValuePair("message", messageT)); doSubmit("chatform", nvp, true); doChatScroll = true; break; case R.id.med_send: int w = walkingPicker.getValue(); int s = sittingPicker.getValue(); if (w == 0 && s == 0) { Toast.makeText(this, R.string.no_time, Toast.LENGTH_SHORT).show(); return; } SharedPreferences.Editor editor = prefs.edit(); editor.putInt("walking", w); editor.putInt("sitting", s); editor.apply(); lastWalking = w * 5; lastSitting = s * 5; startMeditating = true; nvp.add(new BasicNameValuePair("walking", lastWalking + "")); nvp.add(new BasicNameValuePair("sitting", lastSitting + "")); doSubmit("timeform", nvp, true); break; case R.id.med_cancel: Intent rIntent = new Intent(this, ReceiverAlarm.class); PendingIntent walkPendingIntent = PendingIntent.getBroadcast(context, 0, rIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent sitPendingIntent = PendingIntent.getBroadcast(context, 1, rIntent, PendingIntent.FLAG_UPDATE_CURRENT); mAlarmMgr.cancel(walkPendingIntent); mAlarmMgr.cancel(sitPendingIntent); mNM.cancelAll(); doSubmit("cancelform", nvp, true); break; case R.id.smily_button: if (smiliesShell.getVisibility() == View.GONE) smiliesShell.setVisibility(View.VISIBLE); else smiliesShell.setVisibility(View.GONE); break; case R.id.chat_text: smiliesShell.setVisibility(View.GONE); singleClick++; Handler handler = new Handler(); Runnable r = new Runnable() { @Override public void run() { singleClick = 0; } }; if (singleClick == 1) { //Single click handler.postDelayed(r, 250); } else if (singleClick == 2) { //Double click singleClick = 0; ((EditText) findViewById(R.id.chat_text)).setText(""); } break; case R.id.new_commit: Intent i = new Intent(this, ActivityCommit.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i); break; default: smiliesShell.setVisibility(View.GONE); break; } }
From source file:eu.operando.operandoapp.filters.domain.DomainFiltersActivity.java
@OnClick(R.id.add_filter) public void addFilter() { if (viewSelected == 0) { //User Filter View dialogView = getLayoutInflater().inflate(R.layout.user_domain_filter_dialog, null); final EditText input = (EditText) dialogView.findViewById(R.id.filter_content); final CheckBox isWildcard = (CheckBox) dialogView.findViewById(R.id.is_wildcard); AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle("New DomainFilter") .setView(dialogView)/* w ww . j a va 2 s . co m*/ .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { DomainFilter domainFilter = new DomainFilter(); domainFilter.setContent(input.getText().toString().toLowerCase()); domainFilter.setSource(null); domainFilter.setIsWildcard(isWildcard.isChecked()); db.createDomainFilter(domainFilter); updateFiltersList(); userDomainFiltersAdapter.notifyItemInserted(userFilters.size() - 1); recyclerView.scrollToPosition(userFilters.size() - 1); } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); final AlertDialog dialog = builder.create(); input.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (Patterns.DOMAIN_NAME.matcher(s).matches()) { dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true); } else dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); } }); dialog.show(); } else { //Imported filter list final EditText input = new EditText(this); input.setSingleLine(true); //input.setHint("Enter URL"); input.setText(DatabaseHelper.serverUrl + "/blocked_urls"); new AlertDialog.Builder(this).setTitle("Import filters from remote file (hosts file format)") .setView(input).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { final String importUrl = input.getText().toString(); long start = System.currentTimeMillis(); importExternalFilters(importUrl); long end = System.currentTimeMillis(); Toast.makeText(DomainFiltersActivity.this, (end - start) + "ms required", Toast.LENGTH_LONG).show(); } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }).show(); } }
From source file:com.eugene.fithealthmaingit.UI.SaveSearchAddItemActivityMain.java
private void updateItems() { mServingSizeUpdated.setText("1"); LinearLayout changeServing = (LinearLayout) findViewById(R.id.changeServing); changeServing.setOnClickListener(new View.OnClickListener() { @Override//from w w w . ja v a2 s .c o m public void onClick(View v) { AlertDialog.Builder alert = new AlertDialog.Builder(SaveSearchAddItemActivityMain.this); alert.setTitle("Update Serving Size: "); alert.setMessage("Servings Consumed"); final EditText input = new EditText(SaveSearchAddItemActivityMain.this); input.setText(mServingg.getText().toString()); input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); input.selectAll(); input.setGravity(Gravity.CENTER_HORIZONTAL); alert.setView(input, 64, 0, 64, 0); alert.setPositiveButton("Update", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { double values = Double.valueOf(input.getText().toString()); mServingg.setText(df.format(values)); mServingSizeUpdated.setText(df.format(values)); mCalUpdate.setText(dfW.format(Double.valueOf(mCalories) * values)); mCalorieProgress = Double.valueOf(mCalories) * values; mFattieUpdate.setText(df.format(Double.valueOf(mFat) * values)); mFatProgress = Double.valueOf(mFat) * values; mSaturatedFatUpdate.setText(df.format(Double.valueOf(mSaturatedFat) * values)); mCholesterolUpdate.setText(df.format(Double.valueOf(mCholesterol) * values)); mSodiumUpdate.setText(df.format(Double.valueOf(mSodium) * values)); mCarbUpdate.setText(df.format(Double.valueOf(mCarbohydrates) * values)); mCarbProgress = Double.valueOf(mCarbohydrates) * values; mFiberUpdate.setText(df.format(Double.valueOf(mFiber) * values)); mSugarUpdate.setText(df.format(Double.valueOf(mSugar) * values)); mProUpdate.setText(df.format(Double.valueOf(mProtein) * values)); mProteinProgress = Double.valueOf(mProtein) * values; mVitAUpdate.setText(df.format(Double.valueOf(mVitA) * values)); mVitCUpdate.setText(df.format(Double.valueOf(mVitC) * values)); mCalciumUpdate.setText(df.format(Double.valueOf(mCalcium) * values)); mIronUpdate.setText(df.format(Double.valueOf(mIron) * values)); progressBars(); ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(input.getWindowToken(), 0); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(input.getWindowToken(), 0); } }); alert.setCancelable(false); alert.show(); ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)) .toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_NOT_ALWAYS); } }); }
From source file:de.da_sense.moses.client.FormFragment.java
/** * Displays a text question to the user. * @param question the question to be displayed * @param linearLayoutInsideAScrollView the view to add the question to * @param ordinal the ordinal number of the question i.e. 1, 2, 3, 4 or 5 *///from w w w . j a v a2s . c om private void makeTextQuestion(final Question question, LinearLayout linearLayoutInsideAScrollView, int ordinal) { LinearLayout questionContainer = generateQuestionContainer(linearLayoutInsideAScrollView); TextView questionView = new TextView(getActivity()); questionView.setText(ordinal + ". " + question.getTitle()); if (question.isMandatory()) questionView.setTextAppearance(getActivity(), R.style.QuestionTextStyleMandatory); else questionView.setTextAppearance(getActivity(), R.style.QuestionTextStyle); questionContainer.addView(questionView); mQuestionTitleMappings.put(question, questionView); final EditText editText = new EditText(getActivity()); String madeAnswer = question.getAnswer(); if (!madeAnswer.equals(Question.ANSWER_UNANSWERED)) editText.setText(madeAnswer); if (mBelongsTo == WelcomeActivityPagerAdapter.TAB_HISTORY) editText.setEnabled(false); else { // remember the answer as soon as the edittext looses focus editText.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { String newAnswer = editText.getText().toString(); if (!newAnswer.equals(Question.ANSWER_UNANSWERED)) question.setAnswer(newAnswer); } } }); } editText.setVisibility(View.VISIBLE); if (question.getAnswer() != null) { editText.setText(question.getAnswer()); } mQuestionEditTextMappings.put(question, editText); questionContainer.addView(editText); }
From source file:com.googlecode.android_scripting.facade.AndroidFacade.java
private String getInputFromAlertDialog(final String title, final String message, final boolean password) { final FutureActivityTask<String> task = new FutureActivityTask<String>() { @Override// ww w .j a v a 2 s . co m public void onCreate() { super.onCreate(); final EditText input = new EditText(getActivity()); if (password) { input.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); input.setTransformationMethod(new PasswordTransformationMethod()); } AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setTitle(title); alert.setMessage(message); alert.setView(input); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); setResult(input.getText().toString()); finish(); } }); alert.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { dialog.dismiss(); setResult(null); finish(); } }); alert.show(); } }; mTaskQueue.execute(task); try { return task.getResult(); } catch (Exception e) { Log.e("Failed to display dialog.", e); throw new RuntimeException(e); } }
From source file:edu.pitt.gis.uniapp.UniApp.java
/** * Create Custom title bar/* w w w. jav a 2 s .c o m*/ * @return */ protected void createCustomTitleBar() { final UniApp me = this; if (this.customTitleSupported) { getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar); // Go to home final ImageButton homeBtn = (ImageButton) findViewById(R.id.appHomeBtn); homeBtn.setOnClickListener(new ImageButton.OnClickListener() { public void onClick(View v) { me.loadUrl(HOME_URL); } }); // Input address final ImageButton urlBtn = (ImageButton) findViewById(R.id.appUrlBtn); urlBtn.setOnClickListener(new ImageButton.OnClickListener() { public void onClick(View v) { // Open input address dialog // Set an EditText view to get user input final EditText input = new EditText(me); new AlertDialog.Builder(me).setTitle("Input URL").setMessage("Input URL to Load").setView(input) .setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Editable value = input.getText(); me.loadUrl(value.toString()); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. } }).show(); } }); final ImageButton aboutBtn = (ImageButton) findViewById(R.id.aboutBtn); aboutBtn.setOnClickListener(new ImageButton.OnClickListener() { public void onClick(View v) { about.setTitle("About this app"); about.show(); } }); } }
From source file:com.BeatYourRecord.SubmitActivity.java
public String getTagsText() { EditText tagsEdit = (EditText) findViewById(R.id.submitTags); return sanitize(tagsEdit.getText().toString()); }
From source file:com.BeatYourRecord.SubmitActivity.java
public String getTitleText() { EditText titleEdit = (EditText) findViewById(R.id.submitTitle); return sanitize(titleEdit.getText().toString()); }
From source file:com.gimranov.zandy.app.AttachmentActivity.java
@Override protected Dialog onCreateDialog(int id) { final String attachmentKey = b.getString("attachmentKey"); final String itemKey = b.getString("itemKey"); final String content = b.getString("content"); final String mode = b.getString("mode"); AlertDialog dialog;/*from ww w . j a va 2 s . co m*/ switch (id) { case DIALOG_CONFIRM_NAVIGATE: dialog = new AlertDialog.Builder(this).setTitle(getResources().getString(R.string.view_online_warning)) .setPositiveButton(getResources().getString(R.string.view), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // The behavior for invalid URIs might be nasty, but // we'll cross that bridge if we come to it. try { Uri uri = Uri.parse(content); startActivity(new Intent(Intent.ACTION_VIEW).setData(uri)); } catch (ActivityNotFoundException e) { // There can be exceptions here; not sure what would prompt us to have // URIs that the browser can't load, but it apparently happens. Toast.makeText(getApplicationContext(), getResources() .getString(R.string.attachment_intent_failed_for_uri, content), Toast.LENGTH_SHORT).show(); } } }) .setNeutralButton(getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // do nothing } }) .create(); return dialog; case DIALOG_CONFIRM_DELETE: dialog = new AlertDialog.Builder(this) .setTitle(getResources().getString(R.string.attachment_delete_confirm)) .setPositiveButton(getResources().getString(R.string.menu_delete), new DialogInterface.OnClickListener() { @SuppressWarnings("unchecked") public void onClick(DialogInterface dialog, int whichButton) { Attachment a = Attachment.load(attachmentKey, db); a.delete(db); ArrayAdapter<Attachment> la = (ArrayAdapter<Attachment>) getListAdapter(); la.clear(); for (Attachment at : Attachment.forItem(Item.load(itemKey, db), db)) { la.add(at); } } }) .setNegativeButton(getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // do nothing } }) .create(); return dialog; case DIALOG_NOTE: final EditText input = new EditText(this); input.setText(content, BufferType.EDITABLE); AlertDialog.Builder builder = new AlertDialog.Builder(this) .setTitle(getResources().getString(R.string.note)).setView(input).setPositiveButton( getResources().getString(R.string.ok), new DialogInterface.OnClickListener() { @SuppressWarnings("unchecked") public void onClick(DialogInterface dialog, int whichButton) { Editable value = input.getText(); String fixed = value.toString().replaceAll("\n\n", "\n<br>"); if (mode != null && mode.equals("new")) { Log.d(TAG, "Attachment created with parent key: " + itemKey); Attachment att = new Attachment(getBaseContext(), "note", itemKey); att.setNoteText(fixed); att.dirty = APIRequest.API_NEW; att.save(db); } else { Attachment att = Attachment.load(attachmentKey, db); att.setNoteText(fixed); att.dirty = APIRequest.API_DIRTY; att.save(db); } ArrayAdapter<Attachment> la = (ArrayAdapter<Attachment>) getListAdapter(); la.clear(); for (Attachment a : Attachment.forItem(Item.load(itemKey, db), db)) { la.add(a); } la.notifyDataSetChanged(); } }) .setNeutralButton(getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // do nothing } }); // We only want the delete option when this isn't a new note if (mode == null || !"new".equals(mode)) { builder = builder.setNegativeButton(getResources().getString(R.string.menu_delete), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Bundle b = new Bundle(); b.putString("attachmentKey", attachmentKey); b.putString("itemKey", itemKey); removeDialog(DIALOG_CONFIRM_DELETE); AttachmentActivity.this.b = b; showDialog(DIALOG_CONFIRM_DELETE); } }); } dialog = builder.create(); return dialog; case DIALOG_FILE_PROGRESS: mProgressDialog = new ProgressDialog(this); mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); mProgressDialog .setMessage(getResources().getString(R.string.attachment_downloading, b.getString("title"))); mProgressDialog.setIndeterminate(true); return mProgressDialog; default: Log.e(TAG, "Invalid dialog requested"); return null; } }