1. First add a textchangedlistener to the user
2. And then write a change in the text of the monitor
Copy Code code as follows:
Mobile_et.addtextchangedlistener (Textwatcher);
/**
* Real-time monitoring of user input cell phone number, enter the last one after the calculation of the amount of discount
*/
Textwatcher textwatcher = new Textwatcher () {
@Override
public void ontextchanged (charsequence s, int start, int before, int count) {
TODO auto-generated Method Stub
}
@Override
public void beforetextchanged (charsequence s, int start, int count,
int after) {
TODO auto-generated Method Stub
}
@Override
public void aftertextchanged (Editable s) {
if (s.length () = = 11) {
String Amountyuan = Amount_et.gettext (). toString ();//user selected amount + meta
String mobilenum = Mobile_et.gettext (). toString (). Trim ();
int tmobile = Utils.getmobileop (mobilenum);
String disamount= Getdisamount (Tmobile, Amountyuan);
Amount_discount_tv.settext (Disamount);
}
}
};