Currently I have two edit-text,suppose I want to make validation for empty edittext check.What is better way for runtime validation.
My code is;
final EditText ev1 = (EditText) findViewById(R.id.editText1);
final EditText ev2 = (EditText) findViewById(R.id.editText2);
ev1.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View rv, boolean hasFocus) {
if(!hasFocus && ev1.getText().length()==0)
{
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
ev2.clearFocus();
ev1.requestFocus();
}
}, 100);
}
}
});