Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Another option to watch for those events is to extend the <code>Spinner</code> class and use one of its methods(<code>performClick()</code> which will trigger its dialog/popup) followed by monitoring the focus of the window holding this custom <code>Spinner</code>. This should provide you with the wanted closed event for all the possible finishing possibilities(for either the dialog or dropdown mode). </p> <p>The custom <code>Spinner</code> class:</p> <pre><code>public class CustomSpinner extends Spinner { /** * An interface which a client of this Spinner could use to receive * open/closed events for this Spinner. */ public interface OnSpinnerEventsListener { /** * Callback triggered when the spinner was opened. */ void onSpinnerOpened(Spinner spinner); /** * Callback triggered when the spinner was closed. */ void onSpinnerClosed(Spinner spinner); } private OnSpinnerEventsListener mListener; private boolean mOpenInitiated = false; // implement the Spinner constructors that you need @Override public boolean performClick() { // register that the Spinner was opened so we have a status // indicator for when the container holding this Spinner may lose focus mOpenInitiated = true; if (mListener != null) { mListener.onSpinnerOpened(this); } return super.performClick(); } /** * Register the listener which will listen for events. */ public void setSpinnerEventsListener( OnSpinnerEventsListener onSpinnerEventsListener) { mListener = onSpinnerEventsListener; } /** * Propagate the closed Spinner event to the listener from outside if needed. */ public void performClosedEvent() { mOpenInitiated = false; if (mListener != null) { mListener.onSpinnerClosed(this); } } /** * A boolean flag indicating that the Spinner triggered an open event. * * @return true for opened Spinner */ public boolean hasBeenOpened() { return mOpenInitiated; } public void onWindowFocusChanged (boolean hasFocus) { if (hasBeenOpened() &amp;&amp; hasFocus) { performClosedEvent(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload