My Code is: These Take the Custom 3 edittext Than how to adddtextChanged listener to particular foucused Edittext. the Last edittext focues if delete remaining two and if blank third
for(int i=0;i<3;i++)
{
LinearLayout.LayoutParams lparams=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
TextInputLayout input ;
input = new TextInputLayout(this);
input.setLayoutParams(lparams);
et = new EditText(this);
et .setLayoutParams(lparams);
et .setHint(item.getLabel());
et .setMinLines(1);
input.addView(et);
rl_MainLayout1.addView(input);
et.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override
public void afterTextChanged(Editable editable) {
if ( et.getText().toString().trim().isEmpty()) {
input.setError(getString(R.string.msg_errorName));
requestFocus(et);
} else {
input.setErrorEnabled(false);
}
}
});
}