How to get an email entered instantly in android?

I have an EditText view in android .. I want when in the letter the application receives the letter ..

which means you need to enter a listener or event handler to enter each letter

hope my question is clear.

+6
android
source share
6 answers
EditText et = (EditText) findViewById(R.id.EditText01); et.addTextChangedListener( new TextWatcher() { @Override public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { try { char currentChar = arg0.charAt(arg1); // currently typed character } catch(Exception e) { // error } } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } @Override public void afterTextChanged(Editable arg0) { } }); 
+14
source share

You can use the TextView.addTextChangedListener(TextWatcher watcher) method

TextWatcher provides 3 great methods:

 public abstract void afterTextChanged (Editable s) public abstract void beforeTextChanged (CharSequence s, int start, int count, int after) public abstract void onTextChanged (CharSequence s, int start, int before, int count) 

Document here

+4
source share

It would be much simpler to simply override onKeyDown() as follows:

 @Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_Q: // Do your thing here. break; } return super.onKeyDown(keyCode, event); } 
+1
source share

Take a look at the setOnKeyListener method in EditText.

0
source share

analogue Copying text from one EditText field to another in the same operation on the fly, symbolically

0
source share

Vikas's answer almost worked for me, but not quite. Here is what I did to get a typical character printed:

 EditText et = ...; et.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable editable) { } @Override public void onTextChanged(CharSequence s, int start, int count, int after) { if (s.length() > start + count) { char c = s.charAt(start + count); // do something ... } } }); 
0
source share

All Articles