Monday, May 2, 2011

Closable Spinner

I was looking at a way to close a spinner within the code. In the API, I couldn't find any direct method to do so. As a result, I ended up extending the spinner class to have access to the protected method onDetachedFromWindow().

public class SpinnerClosable extends Spinner {

    public SpinnerClosable(Context context) {
        super(context);
    }

    public SpinnerClosable(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    
    public SpinnerClosable(Context mContext, AttributeSet mAttrs, int mDefStyle) {
        super(mContext, mAttrs, mDefStyle);
    }

    public void close() {
        onDetachedFromWindow();
    }

}

No comments:

Post a Comment