Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate androidx.appcompat.widget.AppCompatSpinner #38

Open
xjpmauricio opened this issue Aug 5, 2020 · 4 comments
Open

Validate androidx.appcompat.widget.AppCompatSpinner #38

xjpmauricio opened this issue Aug 5, 2020 · 4 comments

Comments

@xjpmauricio
Copy link

How can I validate a Spinner? I tried adding one of the validations but I get this compilation error:

Cannot find a setter for <androidx.appcompat.widget.AppCompatSpinner app:validateMinLength> that accepts parameter type 'int' If a binding adapter provides the setter, check that the adapter is annotated correctly and that the parameter type matches

@danielsanfr
Copy link
Contributor

Would it be a validation of the quantity of items in Spinner?

@xjpmauricio
Copy link
Author

xjpmauricio commented Aug 11, 2020

Yes, if the spinner has no items.

Another improvement would be to validate if the user has selected an item in the spinner other than the first, where usually we place the text "Please select an item" that usually has no value.

@danielsanfr
Copy link
Contributor

So, the quantity of items in a Spinner doesn't seem to be interesting to add to that library.

Now checking if another item, other than the first one, was selected seems to be very interesting! But for that case, we would have to use a Toast. Since Spinner does not have a setError() method like EditText and TextInputLayout.

If you want to contribute, we can analyze the PR. If not, maybe I'll find some time to do this later.

@xjpmauricio
Copy link
Author

On the spinner, you can do the setError on the TextView it contains. The only problem is if the spinner has no items it will not have the TextView. My initial need was for a validation on the number of items on the spinner; sometimes if you select a parent spinner the child spinner will have no items. It would be nice to have.

You could do also another improvement that I've seen on other web validation libraries which is create a error placeholder that would be placed under the widget being validated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants