material-components / material-components-android-codelabs

Codelabs for Material Components for Android (MDC-Android)
Apache License 2.0
220 stars 160 forks source link

Shrine app failed to launch: MDC 101 - next button error #42

Closed AndreCarvalli closed 5 years ago

AndreCarvalli commented 5 years ago

Is there an issue with my code? when I include this snippet the app fails to launch:

` final TextInputLayout passwordTextInput = view.findViewById(R.id.password_text_input); final TextInputLayout passwordEditText = view.findViewById(R.id.password_edit_text); MaterialButton nextButton = view.findViewById(R.id.next_button);

    // Snippet from "Navigate to the next Fragment" section goes here.

    nextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!isPasswordValid((Editable) passwordEditText.getEditText()))
            {
                passwordTextInput.setError(getString(R.string.shr_error_password));
            }
            else
            {
                passwordTextInput.setError(null);//clear the error

                ((NavigationHost)getActivity()).navigateTo(new ProductGridFragment(),false);// false removes previous screen from back stack
            }
        }
    });

    // Clear the error once more than 8 characters are typed
    passwordEditText.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {

            if (isPasswordValid((Editable) passwordEditText.getEditText()))
            {
                passwordTextInput.setError(null);// clear the error
            }
            return false;
        }
    });`

Help?????

AndreCarvalli commented 5 years ago

Found the error: in variable initialization