tiper / MaterialSpinner

Implementation of a Material Spinner for Android with TextInputLayout functionalities
Apache License 2.0
130 stars 29 forks source link

Add callback support to when the view is focused. #10

Closed hassan31 closed 4 years ago

hassan31 commented 5 years ago

Hi,

I want to fetch some records from the server on click on the spinner, not preloaded or static data. However, I'm able to fetch the records from the server on fragment load and assign the custom adapter to Material Spinner.

But I'm trying to set onClickListener of materialSpinner, as soon as I landed in my fragment app crashes. I saw in your demo repository you have a separate button like Clear and Error Buttons, and you have implemented MaterialSpinner.onClick method. But that will not help me to call the api on click of spinner and then load the data in spinner.

Could you help me in this regard if there is any possible solution you have already in that and I could not find it? I'm new in android so could not find the way to resolve this issue.

Error Unable to start activity ComponentInfo{com.tiper.demo/com.tiper.materialspinner.sample.MainActivity}: java.lang.RuntimeException: Don't call setOnClickListener.You probably want setOnItemClickListener instead.

Thanks in advance.

Kind Regards, Hassan

tiper commented 5 years ago

Hi @hassan31 Looking into the stacktrace we are able to check the reason why it is crashing.

Don't call setOnClickListener.You probably want setOnItemClickListener instead.

Let me known if it helps.

hassan31 commented 5 years ago

Hi @tiper , No I don't want setOnItemClickListener, As I've explained in the above-detailed message that I want an api call on click of the Material Spinner not on it's selected item.

So I want the click listener of Material Spinner rathaer On its item click.

tiper commented 4 years ago

Hi @hassan31 I just release version 1.4.0 which allows you to set a onFocusChangeListener. You should be able to trigger your request when the callback is triggered when the hasFocus has its value true.

Please let me know if you encounter any issues.

hassan31 commented 4 years ago

@tiper Thank you for the new enhancement, I'll check this feature and let you know if it works and useful for me. And apologize for the delayed response.