EditText etUserName = (EditText) findViewById(R.id.txtUsername); String strUserName = etUserName.getText().toString(); if(TextUtils.isEmpty(strUserName)) { etUserName.setError("Your message"); return; }
final EditText editText=(EditText) findViewById(R.id.edit); editText.setImeActionLabel("",EditorInfo.IME_ACTION_NEXT); editText.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if(actionId==EditorInfo.IME_ACTION_NEXT){ if( editText.getText().toString().trim().equalsIgnoreCase("")) editText.setError("Please enter some thing!!!"); else Toast.makeText(getApplicationContext(),"Notnull",Toast.LENGTH_SHORT).show(); } return false; } });
private void attemptEncrypt() { mPlaintextView.setError(null); mCiphertextView.setError(null); mCiphertextView.setText(""); try { byte[] plaintext = mPlaintextView.getText().toString().getBytes("UTF-8"); byte[] ciphertext = mApplication.aead.encrypt(plaintext, EMPTY_ASSOCIATED_DATA); mCiphertextView.setText(base64Encode(ciphertext)); } catch (UnsupportedEncodingException | GeneralSecurityException | IllegalArgumentException e) { mCiphertextView.setError( String.format("%s: %s", getString(R.string.error_cannot_encrypt), e.toString())); mPlaintextView.requestFocus(); } }
private void attemptDecrypt() { mPlaintextView.setError(null); mPlaintextView.setText(""); mCiphertextView.setError(null); try { byte[] ciphertext = base64Decode(mCiphertextView.getText().toString()); byte[] plaintext = mApplication.aead.decrypt(ciphertext, EMPTY_ASSOCIATED_DATA); mPlaintextView.setText(new String(plaintext, "UTF-8")); } catch (UnsupportedEncodingException | GeneralSecurityException | IllegalArgumentException e) { mPlaintextView.setError( String.format("%s: %s", getString(R.string.error_cannot_decrypt), e.toString())); mCiphertextView.requestFocus(); } }
@Override public void setPasswordError() { password.setError(getString(R.string.password_error)); }
@Override public void setUsernameError() { username.setError(getString(R.string.username_error)); }
/** * Called when the "Save" button is clicked. */ public void onSaveClick(View view) { // Don't save if the fields do not validate. if (!mEmailValidator.isValid()) { mEmailText.setError("Invalid email"); Log.w(TAG, "Not saving personal information: Invalid email"); return; } // Get the text from the input fields. String name = mNameText.getText().toString(); Calendar dateOfBirth = Calendar.getInstance(); dateOfBirth.set(mDobPicker.getYear(), mDobPicker.getMonth(), mDobPicker.getDayOfMonth()); String email = mEmailText.getText().toString(); // Create a Setting model class to persist. SharedPreferenceEntry sharedPreferenceEntry = new SharedPreferenceEntry(name, dateOfBirth, email); // Persist the personal information. boolean isSuccess = mSharedPreferencesHelper.savePersonalInfo(sharedPreferenceEntry); if (isSuccess) { Toast.makeText(this, "Personal information saved", Toast.LENGTH_LONG).show(); Log.i(TAG, "Personal information saved"); } else { Log.e(TAG, "Failed to write personal information to SharedPreferences"); } }
etInput2.setError("Please Enter Item"); return false; } else {
@Override public void onClick(View v) { if (mToDoTextBodyEditText.length() <= 0) { mToDoTextBodyEditText.setError(getString(R.string.todo_error)); } else if (mUserReminderDate != null && mUserReminderDate.before(new Date())) { app.send(this, "Action", "Date in the Past"); makeResult(RESULT_CANCELED); } else { app.send(this, "Action", "Make Todo"); makeResult(RESULT_OK); getActivity().finish(); } hideKeyboard(mToDoTextBodyEditText); hideKeyboard(mToDoTextBodyDescription); } });
void onOK(){ fieldView.setError(null); result = fieldView.getText().toString(); if(result.equals("") && !allowEmpty){ fieldView.setError(getString(R.string.field_required)); fieldView.requestFocus(); return; } if(runnable!=null) runnable.run(); dismissAllowingStateLoss(); } void setRunnable(Runnable runnable){
/** * Resolve an issue where the error icon is hidden under some cases in JB * due to a bug http://code.google.com/p/android/issues/detail?id=40417 */ @Override public void setError(CharSequence error, Drawable icon) { super.setError(error, icon); lastErrorIcon = icon; // if the error is not null, and we are in JB, force // the error to show if (error != null /* !isFocused() && */) { showErrorIconHax(icon); } }
void attemptStart(){ pinDelayView.setError(null); lockedDelayView.setError(null); if(ap==null && custom_mac==null){ Snackbar.make(fragmentView, getString(R.string.select_ap), Snackbar.LENGTH_LONG).show(); }else{ if(pinDelayView.getText().toString().equals("")){ pinDelayView.setError(getString(R.string.field_required)); pinDelayView.requestFocus(); return; } if(lockedDelayView.getText().toString().equals("")){ lockedDelayView.setError(getString(R.string.field_required)); lockedDelayView.requestFocus(); return; } task = new ReaverTask(); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } ReaverFragment setAutostart(boolean autostart){
void attemptExport(boolean override){ filenameView.setError(null); String filename = filenameView.getText().toString(); if(filename.equals("")){ filenameView.setError(getString(R.string.field_required)); filenameView.requestFocus(); return; } if(override){ export(new File(filename)); }else{ File out_file = new File(filename); if(out_file.exists()){ filenameView.setError(getString(R.string.output_file_exists)); filenameView.requestFocus(); }else{ export(out_file); } } } void export(File out_file){
public void onTextChanged(CharSequence s, int start, int before, int count) { if (!TextUtils.isEmpty(s) && isErrorShown()) { try { TextInputLayout textInputLayout = (TextInputLayout) editText.getParent(); textInputLayout.setErrorEnabled(false); } catch (Throwable e) { editText.setError(null); } } } };
out_file.createNewFile(); if(!out_file.canWrite()){ filenameView.setError(getString(R.string.output_file_cant_write)); filenameView.requestFocus(); return; }catch(IOException e){ Log.e("HIJACKER/ExportDialog", "Exception: " + e.toString()); filenameView.setError(getString(R.string.file_not_created)); filenameView.requestFocus();
void attemptStart(){ capfileView.setError(null); wordlistView.setError(null); String capfile = capfileView.getText().toString(); String wordlist = wordlistView.getText().toString(); capfileView.setError(getString(R.string.capfile_invalid)); capfileView.requestFocus(); return; capfileView.setError(getString(R.string.cap_notfound)); capfileView.requestFocus(); return; wordlistView.setError(getString(R.string.wordlist_invalid)); wordlistView.requestFocus(); return; wordlistView.setError(getString(R.string.wordlist_notfound)); wordlistView.requestFocus(); return;
@Override public void showUIError() { if (mValidator.hasErrorMessage()) { try { TextInputLayout parent = (TextInputLayout) editText.getParent(); parent.setErrorEnabled(true); parent.setError(mValidator.getErrorMessage()); } catch (Throwable e) { editText.setError(mValidator.getErrorMessage()); } } }
public void performValidation() { getEditText().setError(null); if (editTextValidator.testValidity()) {