Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1bba846e authored by Adam Powell's avatar Adam Powell Committed by Android (Google) Code Review
Browse files

Merge "Added ListPopupWindow. Refactored AutoCompleteTextView and Spinner...

Merge "Added ListPopupWindow. Refactored AutoCompleteTextView and Spinner (optionally) to use it. Added associated styles."
parents eefd63e3 c3fa6304
Loading
Loading
Loading
Loading
+708 −0
Original line number Diff line number Diff line
@@ -16883,6 +16883,17 @@
 visibility="public"
>
</field>
<field name="Widget_Spinner_DropDown"
 type="int"
 transient="false"
 volatile="false"
 value="16973970"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="Widget_TabWidget"
 type="int"
 transient="false"
@@ -211630,6 +211641,665 @@
</parameter>
</method>
</interface>
<class name="ListPopupWindow"
 extends="java.lang.Object"
 abstract="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<constructor name="ListPopupWindow"
 type="android.widget.ListPopupWindow"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="context" type="android.content.Context">
</parameter>
</constructor>
<constructor name="ListPopupWindow"
 type="android.widget.ListPopupWindow"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="context" type="android.content.Context">
</parameter>
<parameter name="attrs" type="android.util.AttributeSet">
</parameter>
</constructor>
<constructor name="ListPopupWindow"
 type="android.widget.ListPopupWindow"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="context" type="android.content.Context">
</parameter>
<parameter name="attrs" type="android.util.AttributeSet">
</parameter>
<parameter name="defStyleAttr" type="int">
</parameter>
</constructor>
<constructor name="ListPopupWindow"
 type="android.widget.ListPopupWindow"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="context" type="android.content.Context">
</parameter>
<parameter name="attrs" type="android.util.AttributeSet">
</parameter>
<parameter name="defStyleAttr" type="int">
</parameter>
<parameter name="defStyleRes" type="int">
</parameter>
</constructor>
<method name="clearListSelection"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="dismiss"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getAnchorView"
 return="android.view.View"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getAnimationStyle"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getBackground"
 return="android.graphics.drawable.Drawable"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getHeight"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getHorizontalOffset"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getInputMethodMode"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getListView"
 return="android.widget.ListView"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getPromptPosition"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getSelectedItem"
 return="java.lang.Object"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getSelectedItemId"
 return="long"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getSelectedItemPosition"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getSelectedView"
 return="android.view.View"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getSoftInputMode"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getVerticalOffset"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getWidth"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="isInputMethodNotNeeded"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="isModal"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="isShowing"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="onKeyDown"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="keyCode" type="int">
</parameter>
<parameter name="event" type="android.view.KeyEvent">
</parameter>
</method>
<method name="onKeyPreIme"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="keyCode" type="int">
</parameter>
<parameter name="event" type="android.view.KeyEvent">
</parameter>
</method>
<method name="onKeyUp"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="keyCode" type="int">
</parameter>
<parameter name="event" type="android.view.KeyEvent">
</parameter>
</method>
<method name="performItemClick"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="position" type="int">
</parameter>
</method>
<method name="postShow"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="setAdapter"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="adapter" type="android.widget.ListAdapter">
</parameter>
</method>
<method name="setAnchorView"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="anchor" type="android.view.View">
</parameter>
</method>
<method name="setAnimationStyle"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="animationStyle" type="int">
</parameter>
</method>
<method name="setBackgroundDrawable"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="d" type="android.graphics.drawable.Drawable">
</parameter>
</method>
<method name="setHeight"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="height" type="int">
</parameter>
</method>
<method name="setHorizontalOffset"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="offset" type="int">
</parameter>
</method>
<method name="setInputMethodMode"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="mode" type="int">
</parameter>
</method>
<method name="setListSelector"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="selector" type="android.graphics.drawable.Drawable">
</parameter>
</method>
<method name="setModal"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="modal" type="boolean">
</parameter>
</method>
<method name="setOnItemClickListener"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="clickListener" type="android.widget.AdapterView.OnItemClickListener">
</parameter>
</method>
<method name="setOnItemSelectedListener"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="selectedListener" type="android.widget.AdapterView.OnItemSelectedListener">
</parameter>
</method>
<method name="setPromptPosition"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="position" type="int">
</parameter>
</method>
<method name="setPromptView"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="prompt" type="android.view.View">
</parameter>
</method>
<method name="setSelection"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="position" type="int">
</parameter>
</method>
<method name="setSoftInputMode"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="mode" type="int">
</parameter>
</method>
<method name="setVerticalOffset"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="offset" type="int">
</parameter>
</method>
<method name="setWidth"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="width" type="int">
</parameter>
</method>
<method name="show"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<field name="INPUT_METHOD_FROM_FOCUSABLE"
 type="int"
 transient="false"
 volatile="false"
 value="0"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="INPUT_METHOD_NEEDED"
 type="int"
 transient="false"
 volatile="false"
 value="1"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="INPUT_METHOD_NOT_NEEDED"
 type="int"
 transient="false"
 volatile="false"
 value="2"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="MATCH_PARENT"
 type="int"
 transient="false"
 volatile="false"
 value="-1"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="POSITION_PROMPT_ABOVE"
 type="int"
 transient="false"
 volatile="false"
 value="0"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="POSITION_PROMPT_BELOW"
 type="int"
 transient="false"
 volatile="false"
 value="1"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="WRAP_CONTENT"
 type="int"
 transient="false"
 volatile="false"
 value="-2"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
</class>
<class name="ListView"
 extends="android.widget.AbsListView"
 abstract="false"
@@ -212670,6 +213340,22 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="context" type="android.content.Context">
</parameter>
<parameter name="attrs" type="android.util.AttributeSet">
</parameter>
<parameter name="defStyleAttr" type="int">
</parameter>
<parameter name="defStyleRes" type="int">
</parameter>
</constructor>
<constructor name="PopupWindow"
 type="android.widget.PopupWindow"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</constructor>
<constructor name="PopupWindow"
 type="android.widget.PopupWindow"
@@ -217256,6 +217942,28 @@
<parameter name="promptId" type="int">
</parameter>
</method>
<field name="MODE_DIALOG"
 type="int"
 transient="false"
 volatile="false"
 value="0"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="MODE_DROPDOWN"
 type="int"
 transient="false"
 volatile="false"
 value="1"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
</class>
<interface name="SpinnerAdapter"
 abstract="true"
+90 −590

File changed.

Preview size limit exceeded, changes collapsed.

+1215 −0

File added.

Preview size limit exceeded, changes collapsed.

+23 −12
Original line number Diff line number Diff line
@@ -16,27 +16,28 @@

package android.widget;

import com.android.internal.R;
import java.lang.ref.WeakReference;

import android.content.Context;
import android.content.res.TypedArray;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.Gravity;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnScrollChangedListener;
import android.view.View.OnTouchListener;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.os.IBinder;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.view.View.OnTouchListener;
import android.view.ViewTreeObserver.OnScrollChangedListener;

import java.lang.ref.WeakReference;
import com.android.internal.R;

/**
 * <p>A popup window that can be used to display an arbitrary view. The popup
@@ -157,12 +158,21 @@ public class PopupWindow {
     * <p>The popup does provide a background.</p>
     */
    public PopupWindow(Context context, AttributeSet attrs, int defStyle) {
        this(context, attrs, defStyle, 0);
    }
    
    /**
     * <p>Create a new, empty, non focusable popup window of dimension (0,0).</p>
     * 
     * <p>The popup does not provide a background.</p>
     */
    public PopupWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        mContext = context;
        mWindowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);

        TypedArray a =
            context.obtainStyledAttributes(
                attrs, com.android.internal.R.styleable.PopupWindow, defStyle, 0);
                attrs, com.android.internal.R.styleable.PopupWindow, defStyleAttr, defStyleRes);

        mBackground = a.getDrawable(R.styleable.PopupWindow_popupBackground);

@@ -1315,6 +1325,7 @@ public class PopupWindow {
    }

    private class PopupViewContainer extends FrameLayout {
        private static final String TAG = "PopupWindow.PopupViewContainer";

        public PopupViewContainer(Context context) {
            super(context);
+198 −14
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.DialogInterface.OnClickListener;
import android.content.res.TypedArray;
import android.database.DataSetObserver;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

@@ -37,9 +38,19 @@ import android.view.ViewGroup;
 */
@Widget
public class Spinner extends AbsSpinner implements OnClickListener {
    private static final String TAG = "Spinner";
    
    private CharSequence mPrompt;
    private AlertDialog mPopup;
    /**
     * Use a dialog window for selecting spinner options.
     */
    public static final int MODE_DIALOG = 0;
    
    /**
     * Use a dropdown anchored to the Spinner for selecting spinner options.
     */
    public static final int MODE_DROPDOWN = 1;
    
    private SpinnerPopup mPopup;
    
    public Spinner(Context context) {
        this(context, null);
@@ -55,11 +66,44 @@ public class Spinner extends AbsSpinner implements OnClickListener {
        TypedArray a = context.obtainStyledAttributes(attrs,
                com.android.internal.R.styleable.Spinner, defStyle, 0);
        
        mPrompt = a.getString(com.android.internal.R.styleable.Spinner_prompt);
        final int mode = a.getInt(com.android.internal.R.styleable.Spinner_spinnerMode,
                MODE_DIALOG);
        
        switch (mode) {
        case MODE_DIALOG: {
            mPopup = new DialogPopup();
            break;
        }
        
        case MODE_DROPDOWN: {
            final int hintResource = a.getResourceId(
                    com.android.internal.R.styleable.Spinner_popupPromptView, 0);

            DropdownPopup popup = new DropdownPopup(context, attrs, defStyle, hintResource);

            popup.setBackgroundDrawable(a.getDrawable(
                    com.android.internal.R.styleable.Spinner_popupBackground));
            popup.setVerticalOffset(a.getDimensionPixelOffset(
                    com.android.internal.R.styleable.Spinner_dropDownVerticalOffset, 0));
            popup.setHorizontalOffset(a.getDimensionPixelOffset(
                    com.android.internal.R.styleable.Spinner_dropDownHorizontalOffset, 0));

            mPopup = popup;
            break;
        }
        }
        
        mPopup.setPromptText(a.getString(com.android.internal.R.styleable.Spinner_prompt));

        a.recycle();
    }
    
    @Override
    public void setAdapter(SpinnerAdapter adapter) {
        super.setAdapter(adapter);
        mPopup.setAdapter(new DropDownAdapter(adapter));
    }

    @Override
    public int getBaseline() {
        View child = null;
@@ -246,15 +290,10 @@ public class Spinner extends AbsSpinner implements OnClickListener {
        
        if (!handled) {
            handled = true;
            Context context = getContext();
            
            final DropDownAdapter adapter = new DropDownAdapter(getAdapter());

            AlertDialog.Builder builder = new AlertDialog.Builder(context);
            if (mPrompt != null) {
                builder.setTitle(mPrompt);
            if (!mPopup.isShowing()) {
                mPopup.show();
            }
            mPopup = builder.setSingleChoiceItems(adapter, getSelectedItemPosition(), this).show();
        }

        return handled;
@@ -271,7 +310,7 @@ public class Spinner extends AbsSpinner implements OnClickListener {
     * @param prompt the prompt to set
     */
    public void setPrompt(CharSequence prompt) {
        mPrompt = prompt;
        mPopup.setPromptText(prompt);
    }

    /**
@@ -279,16 +318,42 @@ public class Spinner extends AbsSpinner implements OnClickListener {
     * @param promptId the resource ID of the prompt to display when the dialog is shown
     */
    public void setPromptId(int promptId) {
        mPrompt = getContext().getText(promptId);
        setPrompt(getContext().getText(promptId));
    }

    /**
     * @return The prompt to display when the dialog is shown
     */
    public CharSequence getPrompt() {
        return mPrompt;
        return mPopup.getHintText();
    }
    
    /*
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (mPopup.onKeyDown(keyCode, event)) {
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
    
    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        if (mPopup.onKeyUp(keyCode, event)) {
            return true;
        }
        return super.onKeyUp(keyCode, event);
    }
    
    @Override
    public boolean onKeyPreIme(int keyCode, KeyEvent event) {
        if (mPopup.onKeyPreIme(keyCode, event)) {
            return true;
        }
        return super.onKeyPreIme(keyCode, event);
    }
    */
    
    /**
     * <p>Wrapper class for an Adapter. Transforms the embedded Adapter instance
     * into a ListAdapter.</p>
@@ -384,4 +449,123 @@ public class Spinner extends AbsSpinner implements OnClickListener {
            return getCount() == 0;
        }
    }
    
    /**
     * Implements some sort of popup selection interface for selecting a spinner option.
     * Allows for different spinner modes.
     */
    private interface SpinnerPopup {
        public void setAdapter(ListAdapter adapter);
        
        /**
         * Show the popup
         */
        public void show();
        
        /**
         * Dismiss the popup
         */
        public void dismiss();
        
        /**
         * @return true if the popup is showing, false otherwise.
         */
        public boolean isShowing();
        
        /**
         * Set hint text to be displayed to the user. This should provide
         * a description of the choice being made.
         * @param hintText Hint text to set.
         */
        public void setPromptText(CharSequence hintText);
        public CharSequence getHintText();
    }
    
    private class DialogPopup implements SpinnerPopup, DialogInterface.OnClickListener {
        private AlertDialog mPopup;
        private ListAdapter mListAdapter;
        private CharSequence mPrompt;

        public void dismiss() {
            mPopup.dismiss();
            mPopup = null;
        }

        public boolean isShowing() {
            return mPopup != null ? mPopup.isShowing() : false;
        }

        public void setAdapter(ListAdapter adapter) {
            mListAdapter = adapter;
        }

        public void setPromptText(CharSequence hintText) {
            mPrompt = hintText;
        }
        
        public CharSequence getHintText() {
            return mPrompt;
        }

        public void show() {
            AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
            if (mPrompt != null) {
                builder.setTitle(mPrompt);
            }
            mPopup = builder.setSingleChoiceItems(mListAdapter,
                    getSelectedItemPosition(), this).show();
        }
        
        public void onClick(DialogInterface dialog, int which) {
            setSelection(which);
            dismiss();
        }
    }
    
    private class DropdownPopup extends ListPopupWindow implements SpinnerPopup {
        private CharSequence mHintText;
        private TextView mHintView;
        private int mHintResource;
        
        public DropdownPopup(Context context, AttributeSet attrs,
                int defStyleRes, int hintResource) {
            super(context, attrs, 0, defStyleRes);
            
            mHintResource = hintResource;
            
            setAnchorView(Spinner.this);
            setModal(true);
            setPromptPosition(POSITION_PROMPT_BELOW);
            setOnItemClickListener(new OnItemClickListener() {
                public void onItemClick(AdapterView parent, View v, int position, long id) {
                    Spinner.this.setSelection(position);
                    dismiss();
                }
            });
        }
        
        public CharSequence getHintText() {
            return mHintText;
        }
        
        public void setPromptText(CharSequence hintText) {
            mHintText = hintText;
            if (mHintView != null) {
                mHintView.setText(hintText);
            }
        }
        
        public void show() {
            if (mHintView == null) {
                final TextView textView = (TextView) LayoutInflater.from(getContext()).inflate(
                        mHintResource, null).findViewById(com.android.internal.R.id.text1);
                textView.setText(mHintText);
                setPromptView(textView);
                mHintView = textView;
            }
            super.show();
            getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
            setSelection(Spinner.this.getSelectedItemPosition());
        }
    }
}
Loading