views:

136

answers:

2

I can see keys on the device fire for a particular View with onKey, but this doesn't fire when keys on the software keyboard are pressed.

I am trying to build a dynamic UI that recalculates a value as the input changes, while it's changing. Is there a way to capture either that the value of the EditText has changed?

+4  A: 

Yeah, you just need to add a TextChangedListener:

textEdit.addTextChangedListener(new TextWatcher(){

  @Override
  public void afterTextChanged(Editable editable)
  {
   // Do Stuff

  }

  @Override
  public void beforeTextChanged(CharSequence text, int start, int count, int after)
  {
   // Do Stuff

  }

  @Override
  public void onTextChanged(CharSequence arg0, int start, int before, int count)
  {
   // Do Stuff

  }

 });

You can find more info here:

http://developer.android.com/intl/de/reference/android/text/TextWatcher.html

CaseyB
+1  A: 

Per: http://developer.android.com/reference/android/text/TextWatcher.html

    editText.addTextChangedListener(new TextWatcher() {
        public void onTextChanged (CharSequence s, int start, int before, int count) {

        }
        public void afterTextChanged (Editable s) {

        }
        public void beforeTextChanged (CharSequence s, int start, int count, int after) {

        }
    });
Dinedal