Smitha_nj Smitha_nj - 3 years ago 87
Android Question

validation of EditText by TextWatcher or AwesomeValidation Library

I have created a Registration form with Name,age,gender and salary.Now i am trying to do validation for all the fields.
I came up with lot of examples n links on validation using Text Watcher and various validation libraries like Awesome Validation,Android-Validator Library etc.
I am bit confused here,I need to know which one to use ? and why?
A little bit of explanation will be helpful.

Answer Source

you can create validation as per your requirement i think its not good idea to use validation libraries

you can apply validation to your form controls like this

 EditText editText = .findViewById(R.id.btn_FBShare);
    Button button = (Button) findViewById(R.id.btn_FBShare);
    //set validation on button click like this
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (editText.getText().toString().isEmpty()) {
                editText.setError("enetr user name");
                Toast.makeText(getActivity(), "Please enetr user name", Toast.LENGTH_SHORT).show();
            }else {
                Toast.makeText(getContext(), "Valid Data", Toast.LENGTH_SHORT).show();
            }
        }
    });

let me now if you have any doubt

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download