List of usage examples for android.text TextWatcher TextWatcher
TextWatcher
From source file:com.grass.caishi.cc.activity.LoginActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_login); // progressShow = true; userDao = new UserDao(LoginActivity.this); usernameEditText = (EditText) findViewById(R.id.username); passwordEditText = (EditText) findViewById(R.id.password); // ????/*from w ww.j a va 2 s. c o m*/ // if (DemoApplication.getInstance().getUserName() != null && // DemoApplication.getInstance().getPassword() != null) { if (MyApplication.getInstance().getUser() != null && MyApplication.getInstance().getPassword() != null) { startActivity(new Intent(this, MainActivity.class)); finish(); } // ???? usernameEditText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { passwordEditText.setText(null); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); // mAuthorization = Frontia.getAuthorization();// DeviceUuidFactory Deviceid = new DeviceUuidFactory(this); did = Deviceid.getDeviceUuid().toString(); findViewById(R.id.tv_goto_login).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { login(); } }); findViewById(R.id.tv_goto_register).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { register(); } }); }
From source file:mp.paschalis.LentBookActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); app = (App) getApplication();//from w w w.j a v a 2 s .c o m setContentView(R.layout.activity_lent_book); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Get arguments (User,Destination,ISBN) final Bundle extras = getIntent().getExtras(); try { final String isbn = extras.getString(App.ExtrasForLentBookActivityISBN); fromEditBookActivity = true; gotISBN = isbn; } catch (Exception e) { Toast.makeText(LentBookActivity.this, "Something went wrong. Please report this", Toast.LENGTH_LONG) .show(); fromEditBookActivity = false; LentBookActivity.this.finish(); } progressBarLentButton = (ProgressBar) findViewById(R.id.progressBarLentButton); buttonLentBook = (Button) findViewById(R.id.buttonLentBook); editTextDestinationUsername = (EditText) findViewById(R.id.editTextDestinationUser); textViewLentResult = (TextView) findViewById(R.id.textViewLentResult); editTextDestinationUsername.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { if (editTextDestinationUsername.getText().length() >= 4) { buttonLentBook.setEnabled(true); } else { buttonLentBook.setEnabled(false); } } }); buttonLentBook.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { DataClassLentABook data = new DataClassLentABook(); data.destinationUser = editTextDestinationUsername.getText().toString(); data.isbn = gotISBN; new AsyncTaskLentABook().execute(data); } }); }
From source file:com.github.guilhermesgb.marqueeto.sample.LicensesViewPagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, final int position) { LayoutInflater inflater = LayoutInflater.from(context); View view = inflater.inflate(R.layout.form_drivers_license, container, false); final DriversLicenseForm form = new DriversLicenseForm(); ButterKnife.bind(form, view);/*from w w w . ja v a 2s .com*/ container.addView(view); final DriversLicense license; if (position != 0) { license = driversLicenses.get(position - 1); } else { license = new DriversLicense(); } form.nameEditText.setText(license.getName()); form.identityNumberEditText.setText(license.getIdentityNumber()); form.issuingOrgEditText.setText(license.getIssuingOrg()); form.cpfNumberEditText.setText(license.getCpfNumber()); form.cpfNumberEditText.setTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence sequence, int start, int count, int after) { } private boolean isUpdating; private String old = ""; private String unmask(String s) { return s.replaceAll("[.]", "").replaceAll("[-]", "").replaceAll("[/]", "").replaceAll("[(]", "") .replaceAll("[)]", ""); } @Override public void onTextChanged(CharSequence sequence, int start, int before, int count) { String string = unmask(sequence.toString()); String mask = ""; if (isUpdating) { old = string; isUpdating = false; return; } int i = 0; for (char m : "###.###.###-##".toCharArray()) { if (m != '#' && string.length() > old.length()) { mask += m; continue; } try { mask += string.charAt(i); } catch (Exception e) { break; } i++; } isUpdating = true; form.cpfNumberEditText.setText(mask); } @Override public void afterTextChanged(Editable sequence) { } }); form.birthDateEditText.setText(license.getBirthDate()); form.filiationEditText.setText(license.getFiliation()); form.goodThruEditText.setText(license.getGoodThru()); form.issuingDateEditText.setText(license.getIssuingDate()); form.locationEditText.setText(license.getLocation()); form.saveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (validateAllFieldValues(form, context.getString(R.string.label_error_value_cannot_be_empty))) { license.setName(form.nameEditText.getText()); license.setIdentityNumber(form.identityNumberEditText.getText()); license.setIssuingOrg(form.issuingOrgEditText.getText()); license.setCpfNumber(form.cpfNumberEditText.getText()); license.setBirthDate(form.birthDateEditText.getText()); license.setFiliation(form.filiationEditText.getText()); license.setGoodThru(form.goodThruEditText.getText()); license.setIssuingDate(form.issuingDateEditText.getText()); license.setLocation(form.locationEditText.getText()); license.save(); ColoredSnackbar .alert(Snackbar.make(form.saveButton, context.getString(R.string.snackbar_saved_successfully), Snackbar.LENGTH_SHORT)) .show(); if (position == 0) { EventBus.getDefault().post(new NewLicenseEvent()); } else { EventBus.getDefault().post(new UpdateLicenseEvent(license.getCpfNumber())); } } else { ColoredSnackbar.alert(Snackbar.make(form.saveButton, context.getString(R.string.snackbar_save_failed), Snackbar.LENGTH_SHORT)).show(); } } }); form.deleteButton.setVisibility(position == 0 ? View.GONE : View.VISIBLE); form.deleteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new AlertDialog.Builder(context).setTitle(context.getString(R.string.dialog_title_are_you_sure)) .setPositiveButton(context.getString(R.string.dialog_positive), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { license.delete(); ColoredSnackbar.alert(Snackbar.make(form.deleteButton, context.getString(R.string.snackbar_removed_successfully), Snackbar.LENGTH_SHORT)).show(); EventBus.getDefault().post(new DeleteLicenseEvent()); } }) .setNegativeButton(context.getString(R.string.dialog_negative), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }) .show(); } }); return view; }
From source file:com.fimagena.filepicker.NewFolderFragment.java
@NonNull @Override/*w w w . j av a2s.c o m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(R.layout.dialog_folder_name).setTitle(R.string.new_folder) .setNegativeButton(android.R.string.cancel, null).setPositiveButton(android.R.string.ok, null); final AlertDialog dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog1) { final AlertDialog dialog = (AlertDialog) dialog1; final EditText editText = (EditText) dialog.findViewById(R.id.edit_text); Button cancel = dialog.getButton(AlertDialog.BUTTON_NEGATIVE); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dialog.cancel(); } }); final Button ok = dialog.getButton(AlertDialog.BUTTON_POSITIVE); ok.setEnabled(false); // Start disabled ok.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String itemName = editText.getText().toString(); if (validateName(itemName)) { if (listener != null) listener.onNewFolder(itemName); dialog.dismiss(); } } }); editText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) { } @Override public void onTextChanged(final CharSequence s, final int start, final int before, final int count) { } @Override public void afterTextChanged(final Editable s) { ok.setEnabled(validateName(s.toString())); } }); } }); return dialog; }
From source file:fr.cph.chicago.core.fragment.BusFragment.java
private void addView() { busAdapter = new BusAdapter(listView); listView.setAdapter(busAdapter);// w w w .j ava 2 s . com textFilter.setVisibility(TextView.VISIBLE); textFilter.addTextChangedListener(new TextWatcher() { final BusData busData = DataHolder.getInstance().getBusData(); List<BusRoute> busRoutes = null; @Override public void beforeTextChanged(final CharSequence c, final int start, final int count, final int after) { busRoutes = new ArrayList<>(); } @Override public void onTextChanged(final CharSequence c, final int start, final int before, final int count) { final List<BusRoute> busRoutes = busData.getBusRoutes(); final CharSequence trimmed = c.toString().trim(); this.busRoutes.addAll(Stream.of(busRoutes) .filter(busRoute -> StringUtils.containsIgnoreCase(busRoute.getId(), trimmed) || StringUtils.containsIgnoreCase(busRoute.getName(), trimmed)) .collect(Collectors.toList())); } @Override public void afterTextChanged(final Editable s) { busAdapter.setRoutes(busRoutes); busAdapter.notifyDataSetChanged(); } }); }
From source file:com.checktipsplitter.wizard.ui.FreeTextFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mEditText.addTextChangedListener(new TextWatcher() { @Override//from w ww . j av a 2s . c om public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { if (inputType == (InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL)) { mPage.getData().putString(FreeTextPage.DATA_KEY, (!TextUtils.isEmpty(editable.toString())) ? String.valueOf(Float.valueOf(editable.toString())) : null); } else if (inputType == InputType.TYPE_CLASS_NUMBER) { mPage.getData().putString(FreeTextPage.DATA_KEY, (!TextUtils.isEmpty(editable.toString())) ? String.valueOf(Integer.valueOf(editable.toString())) : null); } else { mPage.getData().putString(FreeTextPage.DATA_KEY, (editable != null) ? editable.toString() : null); } mPage.notifyDataChanged(); } }); }
From source file:au.com.domain.AccountsAutoCompleteTextView.java
private void init(Context context) { addView(mAccountsAutocomplete = new AutoCompleteTextView(context)); mAccountsAutocomplete.setImeOptions(EditorInfo.IME_ACTION_NEXT); mAccountsAutocomplete.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); if (TextUtils.isEmpty(getHint())) { setHint("Email"); }//from w w w .java 2 s . c om // TODO Make this a custom attr (currently does nothing) mThreshold = mAccountsAutocomplete.getThreshold(); setAccountOptions(); mAccountsAutocomplete.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean b) { if (b && !isPermissionGranted()) { mAccountsAutocomplete.showDropDown(); } } }); mAccountsAutocomplete.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { String currentText = charSequence.toString(); if (!currentText.equalsIgnoreCase(getContext().getString(R.string.allow_accounts_suggestion))) { mCurrentText = charSequence.toString(); } } @Override public void afterTextChanged(Editable editable) { if (isErrorEnabled()) { setError(null); setErrorEnabled(false); } } }); }
From source file:com.example.android.wizardpager.wizard.ui.ProfessorContactInfoFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mNameView.addTextChangedListener(new TextWatcher() { @Override/*from w w w . j a v a2s . c om*/ public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { mPage.getData().putString(ProfessorContactInfoPage.NAME_DATA_KEY, (editable != null) ? editable.toString() : null); mPage.notifyDataChanged(); } }); mEmailView.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { mPage.getData().putString(ProfessorContactInfoPage.EMAIL_DATA_KEY, (editable != null) ? editable.toString() : null); mPage.notifyDataChanged(); } }); mPhoneView.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { mPage.getData().putString(ProfessorContactInfoPage.PHONE_DATA_KEY, (editable != null) ? editable.toString() : null); mPage.notifyDataChanged(); } }); }
From source file:com.example.mysqltest.Payment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.payment);/*from w w w. ja va 2 s . c om*/ //Intent getNfcLoad = getIntent(); //untuk menerima passing //NFCLoad = getNfcLoad.getStringExtra("nfcLoad"); //data dari activity lain NFCLoad = ScanAndPay.NFCLoad; //disimpan di variabel NFCLoad //txtPayload = (EditText) findViewById(R.id.cobaGetID); //memberi identitas edittext dengan nama txtPayLoad //txtPayload.setText(NFCLoad); /*sellerID = (EditText)findViewById(R.id.editIdPenjual); sellerID.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { // you can call or do what you want with your EditText here idPenjual = sellerID.getText().toString(); } public void beforeTextChanged(CharSequence s, int start, int count, int after) {} public void onTextChanged(CharSequence s, int start, int before, int count) {} });*/ itemID = (EditText) findViewById(R.id.editCode); itemID.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { // you can call or do what you want with your EditText here kodeBarang = itemID.getText().toString(); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); itemPrice = (EditText) findViewById(R.id.editPrice); itemPrice.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { // you can call or do what you want with your EditText here hargaBarang = itemPrice.getText().toString(); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); btnPayment = (Button) findViewById(R.id.btnProcess); btnPayment.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub new GetSaldo().execute(NFCLoad); } }); }
From source file:com.jaymullen.TrailJournal.wizard.ui.LocationFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mStartingLocation.addTextChangedListener(new TextWatcher() { @Override// www.j a v a 2s . c o m public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { mPage.getData().putString(LocationPage.START_DATA_KEY, (editable != null) ? editable.toString() : null); mPage.notifyDataChanged(); } }); mEndingLocation.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { mPage.getData().putString(LocationPage.DESTINATION_DATA_KEY, (editable != null) ? editable.toString() : null); mPage.notifyDataChanged(); } }); }