Wednesday, 16 July 2014

Text change listner on EditText

your xml file contains EditText as
--------------------------------------------------


  <EditText
                        android:id="@+id/fromrate"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"/>



change your java page
---------------------------------------------

EditText txt_from=(EditText)findViewById(R.id.fromrate);

 txt_from.addTextChangedListener(new TextWatcher() {

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub

Toast.makeText(getApplicationContext(), "called when a text added or deleted",200).show();

}

@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub

}

@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "called After  a text added or deleted",200).show();
}
});

No comments:

Post a Comment