List of usage examples for android.widget EditText getText
@Override
public Editable getText()
From source file:com.tdispatch.passenger.fragment.RegisterFragment.java
protected String getEditTextContent(int editTextId) { String result = ""; EditText et = (EditText) mFragmentView.findViewById(editTextId); if (et != null) { result = et.getText().toString(); }/*from w w w . java 2 s . co m*/ return result; }
From source file:dk.moerks.ratebeermobile.Rate.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.rate);// w w w . jav a2s .c o m Bundle extras = getIntent().getExtras(); if (extras != null) { beername = extras.getString("BEERNAME"); beerid = extras.getString("BEERID"); } rateCharleftText = (TextView) findViewById(R.id.rate_label_charleft); rateCharleftText.setText(getText(R.string.rate_charleft) + " 75"); EditText rateComment = (EditText) findViewById(R.id.rate_value_comments); rateComment.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) { int charNumber = s.length(); int resultNumber = 75 - charNumber; if (resultNumber > 0) { rateCharleftText.setText(getText(R.string.rate_charleft) + " " + resultNumber); } else { rateCharleftText.setText(""); } } }); TextView beernameText = (TextView) findViewById(R.id.rate_label_beername); beernameText.setText(beername); Button rateButton = (Button) findViewById(R.id.rate_button); rateButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { EditText comment = (EditText) findViewById(R.id.rate_value_comments); final String commentString = comment.getText().toString(); if (commentString.length() > 74) { Spinner aromaText = (Spinner) findViewById(R.id.rate_value_aroma); Spinner appearanceText = (Spinner) findViewById(R.id.rate_value_appearance); Spinner flavorText = (Spinner) findViewById(R.id.rate_value_flavor); Spinner palateText = (Spinner) findViewById(R.id.rate_value_palate); Spinner overallText = (Spinner) findViewById(R.id.rate_value_overall); final String aromaString = (String) aromaText.getSelectedItem(); final String appearanceString = (String) appearanceText.getSelectedItem(); final String flavorString = (String) flavorText.getSelectedItem(); final String palateString = (String) palateText.getSelectedItem(); final String overallString = (String) overallText.getSelectedItem(); String totalScore = calculateTotalScore(aromaString, appearanceString, flavorString, palateString, overallString); List<NameValuePair> parameters = new ArrayList<NameValuePair>(); parameters.add(new BasicNameValuePair("BeerID", beerid)); parameters.add(new BasicNameValuePair("aroma", aromaString)); parameters.add(new BasicNameValuePair("appearance", appearanceString)); parameters.add(new BasicNameValuePair("flavor", flavorString)); parameters.add(new BasicNameValuePair("palate", palateString)); parameters.add(new BasicNameValuePair("overall", overallString)); parameters.add(new BasicNameValuePair("totalscore", totalScore)); parameters.add(new BasicNameValuePair("Comments", commentString)); new SaveRatingTask(Rate.this).execute(parameters.toArray(new NameValuePair[] {})); SharedPreferences prefs = getSharedPreferences(Settings.PREFERENCETAG, 0); if (prefs.getBoolean("rb_twitter_ratings", false)) { new PostTwitterStatusTask(Rate.this).execute(buildTwitterMessage(totalScore)); } finish(); } else { Toast.makeText(Rate.this, R.string.toast_minimum_length, Toast.LENGTH_LONG).show(); } } private String buildTwitterMessage(String score) { return getString(R.string.twitter_rating_message, beername, score, getUserId()); } private String calculateTotalScore(String aromaString, String appearanceString, String flavorString, String palateString, String overallString) { int aroma = Integer.parseInt(aromaString); int appearance = Integer.parseInt(appearanceString); int flavor = Integer.parseInt(flavorString); int palate = Integer.parseInt(palateString); int overall = Integer.parseInt(overallString); int total = (aroma + appearance + flavor + palate + overall); float totalscore = ((float) total) / 10; String result = "" + totalscore; return result; } }); }
From source file:com.example.hbranciforte.trafficclient.DataTraffic.java
private boolean validateFormatOf(EditText etText, String regexp, String description) { Pattern mPattern = Pattern.compile(regexp); Matcher matcher = mPattern.matcher(etText.getText().toString()); if (!matcher.find()) { etText.setError(description);/*w w w . j a va2s . co m*/ return false; } return true; }
From source file:com.cs411.trackallthethings.Main.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);/*from ww w .jav a 2s . c om*/ //onClickListener to handle the login event on the login button Button submit = (Button) findViewById(R.id.loginsubmit); submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //get the text from the username and password fields EditText username = (EditText) findViewById(R.id.username); EditText password = (EditText) findViewById(R.id.password); String user = username.getText().toString(); String pass = password.getText().toString(); Main.userName = user; Main.passWrd = pass; //if the user has entered nothing, don't bother trying to contact //the server - a safeguard if (user.equals("") || pass.equals("")) return; //otherwise we will contact the server to login //set up and execute the login asynctask //show the loading dialog loggingIn = ProgressDialog.show(Main.this, "", "Logging in...", true); loginTask = new doLogin(Main.this, "http://www.trackallthethings.com/mobile-api/login.php?userName=" + user + "&passWrd=" + pass); loginTask.execute(); } }); }
From source file:es.uja.photofirma.android.SignUpActivity.java
/** * Se ejecuta cuando el usuario pulsa el botn 'Registrar' de la interfaz grfica, permite verficar los * datos del formulario para la posterior conexin con el servidor */// w ww .j a v a 2 s. com public void onDoSignup(View view) { signUpButton.setVisibility(LinearLayout.VISIBLE); tSignupText.setVisibility(TextView.INVISIBLE); tConnectingText.setVisibility(TextView.VISIBLE); spb.setVisibility(LinearLayout.VISIBLE); EditText userPasswordTextEdit = (EditText) findViewById(R.id.signUpActivityPassword); EditText userVPasswordTextEdit = (EditText) findViewById(R.id.signUpActivityVPassword); EditText userNameTextEdit = (EditText) findViewById(R.id.signUpActivityUsername); EditText userEmailTextEdit = (EditText) findViewById(R.id.signUpActivityEmail); userEmail = userEmailTextEdit.getText().toString(); userName = userNameTextEdit.getText().toString(); //longitud contrasea, para comprobacin de la fortaleza userPasswordLenght = userPasswordTextEdit.getText().toString().length(); userVPasswordLenght = userVPasswordTextEdit.getText().toString().length(); userPassword = userPasswordTextEdit.getText().toString(); userVPassword = userVPasswordTextEdit.getText().toString(); if (checkBox.isChecked() == false) { signUpButton.setVisibility(LinearLayout.INVISIBLE); signUpButtonError.setVisibility(LinearLayout.VISIBLE); signUpButtonErrorText.setText(R.string.sign_up_activity_accept_terms_of_use); } else { //Comprobacin de la longitud de la contrasea if (userEmail.length() == 0) { signUpButton.setVisibility(LinearLayout.INVISIBLE); signUpButtonError.setVisibility(LinearLayout.VISIBLE); signUpButtonErrorText.setText(R.string.sign_up_activity_email_required); } else if (userName.length() == 0) { signUpButton.setVisibility(LinearLayout.INVISIBLE); signUpButtonError.setVisibility(LinearLayout.VISIBLE); signUpButtonErrorText.setText(R.string.sign_up_activity_username_required); } else if (userPasswordLenght < 8 && userVPasswordLenght < 8) { //Si la contrasea no es lo suficientemente fuerte notifica al usuario signUpButton.setVisibility(LinearLayout.INVISIBLE); signUpButtonError.setVisibility(LinearLayout.VISIBLE); signUpButtonErrorText.setText(R.string.signup_activity_password_required); } else if (!userPassword.equals(userVPassword)) { signUpButton.setVisibility(LinearLayout.INVISIBLE); signUpButtonError.setVisibility(LinearLayout.VISIBLE); signUpButtonErrorText.setText(R.string.sign_up_activity_password_mismatch); } else { userPassword = StringMD.getStringMessageDigest(userPassword, StringMD.SHA512); userVPassword = StringMD.getStringMessageDigest(userVPassword, StringMD.SHA512); new DoSignup().execute(URL_DO_SIGNUP); } } }
From source file:devbox.com.br.minercompanion.LoginActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); createProgressDialog();//w w w .ja v a 2s. com editText = (EditText) findViewById(R.id.editText); Button login = (Button) findViewById(R.id.button); login.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { EditText editText = (EditText) findViewById(R.id.editText); //if(editText.getText().length() > 0 && isConnected()) { if (editText.getText().length() > 0) { progressDialog.show(); new HttpAsyncTask().execute(url, editText.getText().toString()); } else { Toast.makeText(getApplicationContext(), "Matrcula no preenchida!", Toast.LENGTH_SHORT) .show(); } } }); }
From source file:ar.uba.fi.splitapp.ChatRoomActivity.java
private void addSendListener() { ImageButton sendButton = (ImageButton) this.findViewById(R.id.send); assert sendButton != null; //Debug assert sendButton.setOnClickListener(listener -> { EditText msgView = (EditText) findViewById(R.id.message); assert msgView != null; //Debug assert String message = msgView.getText().toString(); if (message.isEmpty()) { return; }//from w w w . j a v a2 s.c o m sendMessage(message); msgView.setText(""); Utility.hideKeyboard(this); scrollToLast(); }); }
From source file:at.florian_lentsch.expirysync.AddProductActivity.java
/** * Creates a {@link ProductEntry} from the form data * /*from ww w . j av a2 s . c o m*/ * @param article * the article associated with the entry * @return the requested {@link ProductEntry} */ private ProductEntry createProductEntryFromFormData(Article article) { final ProductEntry productEntry = new ProductEntry(); productEntry.article = article; EditText amountField = ((EditText) findViewById(R.id.amount_field)); String amountStr = amountField.getText().toString(); if (amountStr.trim().equals("")) { amountStr = DEFAULT_AMOUNT; } productEntry.amount = Integer.parseInt(amountStr); productEntry.created_at = new DateTime(); productEntry.updated_at = new DateTime(); productEntry.description = ((EditText) findViewById(R.id.product_description_field)).getText().toString(); DatePicker datePicker = (DatePicker) findViewById(R.id.expiration_date_field); productEntry.expiration_date = (new GregorianCalendar(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth())).getTime(); productEntry.location = ProductListActivity.currentLocation; productEntry.inSync = false; return productEntry; }
From source file:com.bt.download.android.gui.adapters.menu.RenameFileMenuAction.java
@Override protected void onClick(Context context) { String filePath = fd.filePath; String name = FilenameUtils.getBaseName(filePath); final String ext = FilenameUtils.getExtension(filePath); final EditText input = new EditText(context); input.setText(name);//from ww w . j a va 2 s.c o m input.selectAll(); UIUtils.showOkCancelDialog(context, input, R.string.rename, new OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String newFileName = input.getText().toString() + "." + ext; if (isValidFileName(newFileName)) { renameFile(newFileName); adapter.notifyDataSetChanged(); } else { // FIXME } } }); }
From source file:com.example.android.donebar.DoneBarActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // BEGIN_INCLUDE (inflate_set_custom_view) // Inflate a "Done/Cancel" custom action bar view. final LayoutInflater inflater = (LayoutInflater) getActionBar().getThemedContext() .getSystemService(LAYOUT_INFLATER_SERVICE); final View customActionBarView = inflater.inflate(R.layout.actionbar_custom_view_done_cancel, null); customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener(new View.OnClickListener() { @Override/* w w w . j a v a 2 s .c o m*/ public void onClick(View v) { // "Done" int id = generateId(); EditText number = (EditText) findViewById(R.id.caller_phone_number); EditText information = (EditText) findViewById(R.id.caller_information); checkAvailability(id, number.getText().toString(), information.getText().toString()); finish(); } }); customActionBarView.findViewById(R.id.actionbar_cancel).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // "Cancel" finish(); } }); // Show the custom action bar view and hide the normal Home icon and title. final ActionBar actionBar = getActionBar(); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE); actionBar.setCustomView(customActionBarView, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // END_INCLUDE (inflate_set_custom_view) setContentView(R.layout.activity_done_bar); }