Closed abhinav011085 closed 6 years ago
How do we use with spinner?
You can accomplish this by providing a custom adapter to saripaar:
Define a new class implementing saripaar viewDataAdapter:
public class AppCompatSpinnerValidatorAdapter implements ViewDataAdapter<AppCompatSpinner,String> { @Override public String getData(AppCompatSpinner view) throws ConversionException { return view.getSelectedItem() != null ? view.getSelectedItem().toString() : ""; } }
and then in the class where you use the validar you register the new custom adapter:
validator.registerAdapter(AppCompatSpinner.class, new AppCompatSpinnerValidatorAdapter());
how to make it work with spinner i.e. selected position must be gt 0