TravelNameTextWatcher textWatcher1 = new TravelNameTextWatcher(obj, holder.getItemInnerView(R.id.et_vacation_travel_person_iden_num), 1);
TravelNameTextWatcher tag1 = (TravelNameTextWatcher) holder.getItemInnerView(R.id.et_vacation_travel_person_iden_num).getTag();
if (tag1 != null) {
((EditText) holder.getItemInnerView(R.id.et_vacation_travel_person_iden_num)).removeTextChangedListener(tag1);
}
((EditText) holder.getItemInnerView(R.id.et_vacation_travel_person_iden_num)).addTextChangedListener(textWatcher1);
//TextWatcher写法
private class TravelNameTextWatcher implements TextWatcher {
private View edit;
private int type;
private VacationTouristNameBean touristNameModel;
public TravelNameTextWatcher(VacationTouristNameBean obj, View view, int type) {
edit = view;
this.type = type;
touristNameModel = obj;
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable editable) {
if (editable != null) {
switch (type) {
case 1:
touristNameModel.cardnumber = editable.toString();
break;
case 2:
touristNameModel.touristname = editable.toString();
break;
case 3:
touristNameModel.fristname = editable.toString();
break;
case 4:
touristNameModel.lastname = editable.toString();
break;
case 5:
touristNameModel.passportcity = editable.toString();
break;
}
}
}
}