tiper / MaterialSpinner

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

performClick() doesn't show Dropdown, Dialog or BottomSheet #24

Open Daphne-CoffeeIT opened 4 years ago

Daphne-CoffeeIT commented 4 years ago

Summary: performClick() doesn't work on MaterialSpinner: Dropdown, Dialog or BottomSheet doesn't show.

In my application, there is a holder around the Spinner. When this holder is clicked, the Spinner should show a Dropdown or Dialog. This works for the normal Spinner. Instead of a Dropdown or Dialog I need a BottomSheet and that's why I started using MaterialSpinner. Unfortunately, performClick() doesn't work for MaterialSpinner. No Dropdown, Dialog or BottomSheet is shown. I was wondering if there's a workaround for this or if this can be fixed.

holder.mStateSpinnerHolder.setOnClickListener(new View.OnClickListener() {
@Override
    public void onClick(View v) {
        holder.mStateSpinner.performClick();
    }
});

Edit: I extracted the code of this library to a project class and I added this method as a temporary workaround:

override fun performClick(): Boolean {
    popup.show(0)
    return super.performClick()
}

This shows the expected behaviour. Next to this method, maybe another method performClick(position: Int) should be added too to maintain the position, but this is not needed in all cases. Could this be updated in the library?

tiper commented 4 years ago

Hi @DaphnevdVeeke can you try version master-3acdbe1cc8-1?

Daphne-CoffeeIT commented 4 years ago

Hi @tiper, it seems that I cannot implement 'com.github.tiper:MaterialSpinner:1.4.2' yet, it fails to resolve. Since I don't have too much time today, I won't be able to manually add the entire library to the project before Thursday. I'll get back with you on Thursday or Friday (or earlier if 1.4.2 is released).

tiper commented 4 years ago

Hi @DaphnevdVeeke you do not need to add the lib manually to your project, just use implementation 'com.github.tiper:MaterialSpinner:master-3acdbe1cc8-1'.

Cheers.

Daphne-CoffeeIT commented 4 years ago

Still gives me errors.

image

tiper commented 4 years ago

@DaphnevdVeeke sorry for the inconvenience if you still can, please try implementation 'com.github.tiper:MaterialSpinner:master-SNAPSHOT

Daphne-CoffeeIT commented 4 years ago

@tiper No problem. That one works indeed. Unfortunately, performClick() is still not working. The BottomSheet is not showing up.