Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Nullable
- @Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
- myView = inflater.inflate( R.layout.efetuarcadastro, container,false);
- myView.findViewById( R.id.cad );
- myView.setOnClickListener( new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- validaCampos();
- }
- /* nome.setOnFocusChangeListener( new View.OnFocusChangeListener() {
- @Override
- public String toString() {
- return "$classname{}";
- }
- @Override
- public void onFocusChange(View view, boolean b) {
- if ((nome.getText().length() < 1))
- {
- nome.setError( "Campo obrigatório" );
- }
- else
- if ((login.getText().length() < 1))
- {
- login.setError( "Campo obrigatório" );
- }
- else
- if ((email.getText().length() < 1))
- {
- email.setError( "Campo obrigatório" );
- }
- }
- } ); */
- EditText nome = myView.findViewById( R.id.nome );
- EditText login = myView.findViewById( R.id.login );
- EditText email = myView.findViewById( R.id.email );
- EditText senha = myView.findViewById( R.id.senha );
- EditText confSenha = myView.findViewById( R.id.confSenha );
- /* nome = (EditText) findViewById( R.id.nome);
- login = (EditText) findViewById(R.id.login);
- email = (EditText) findViewById( R.id.email);
- senha = (EditText) findViewById( R.id.senha);
- confSenha = (EditText) findViewById( confSenha); */
- private void validaCampos() {
- boolean res = false;
- String name = nome.getText().toString();
- String user = login.getText().toString();
- String emails = email.getText().toString();
- String password = senha.getText().toString();
- String confpass = confSenha.getText().toString();
- if (res = verificaCampovazio( name )) {
- nome.requestFocus();
- } else
- if (res = verificaCampovazio( user )) {
- login.requestFocus();
- AlertDialog.Builder Mcampovazio = new AlertDialog.Builder(efetuarcadastro.this.getActivity());
- } else
- if (res = !emailValidar( emails )) {
- email.requestFocus();
- } else
- if (res = verificaCampovazio( password )) {
- senha.requestFocus();
- } else
- if (res = verificaCampovazio( confpass )) {
- confSenha.requestFocus();
- if (res) {
- AlertDialog.Builder Mcampovazio = new AlertDialog.Builder(efetuarcadastro.this.getActivity());
- Mcampovazio.setTitle( "Aviso: " );
- Mcampovazio.setMessage( "Há campos inválidos ou sem preenchimento" );
- Mcampovazio.setNeutralButton( "OK",null );
- Mcampovazio.show(); }
- }
- }
- private boolean verificaCampovazio(String valor) {
- Boolean resultado = (TextUtils.isEmpty( valor ) || valor.trim().isEmpty());
- return resultado;
- }
- private boolean emailValidar(String email) {
- Boolean resultado = (!verificaCampovazio( email ) && Patterns.EMAIL_ADDRESS.matcher( email ).matches());
- return resultado;
- }
- } );
- return myView;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement