michaelprimez / searchablespinner

Searchable Spinner
Apache License 2.0
314 stars 102 forks source link

close by clicking outside #6

Closed Elessawy closed 7 years ago

Elessawy commented 7 years ago

drop down list does not close after clicking outside it. is there any method to force close the drop down list?

PatilAbhi commented 7 years ago

Hello , Did You Find Any Method to do the same ???

Elessawy commented 7 years ago

no

michaelprimez commented 7 years ago

Hi guys, The problem was that clicking inside the search is considered clicking outside the drop down window. So, a new method added

mSearchableSpinner.isInsideSearchEditText(event)

Thus, we can define an on Touch listener and check if the touch is or not inside the search and dismiss the popup window, like this:

@Override
public boolean onTouchEvent(MotionEvent event) {
        if (!mSearchableSpinner.isInsideSearchEditText(event)) {
            mSearchableSpinner.hideEdit();
        }
        return super.onTouchEvent(event);
}
Elessawy commented 7 years ago

Thanks for your efforts, my issue has been solved. However, in my activity I'm using three spinners and on opening one spinner then click the second spinner to open it, the first spinner doesn't close. I used a view covers each spinner and set a touch listener on it where I can close other spinners.

mSpinner1TouchView.setOnTouchListener(new View.OnTouchListener() {

            @Override

            public boolean onTouch(View v, MotionEvent event) {

                mSpinner2.hideEdit();

                mSpinner3.hideEdit();

                return false;
            }

        });

thank you again for your amazing library and your fast response.

michaelprimez commented 7 years ago

Hi @Elessawy

You can use the version 1.0.7. A new status listener added, the example project also contains an example. In short :

mSearchableSpinner.setStatusListener(new IStatusListener() {
     @Override
     public void spinnerIsOpening() {
           mSearchableSpinner1.hideEdit();
           mSearchableSpinner2.hideEdit();
     }
     @Override
     public void spinnerIsClosing() { }
});

Thanks

Elessawy commented 7 years ago

Thanks Michael. I will use the latest version. Great work, keep going :)

PatilAbhi commented 7 years ago

It Says Cannot Resolve Symbol 'IStatusListener'

Elessawy commented 7 years ago

make sure that you are using the latest version (1.0.7) and that the listener is imported

import gr.escsoft.michaelprimez.searchablespinner.interfaces.IStatusListener;

amitprasad0 commented 4 years ago

i tried above code but not working