Example #1
0
        /// <summary>
        /// Construct a new spinner with the given context's theme, the supplied attribute set,
        /// and default style.
        /// </summary>
        /// <remarks>
        /// Construct a new spinner with the given context's theme, the supplied attribute set,
        /// and default style. <code>mode</code> may be one of
        /// <see cref="MODE_DIALOG">MODE_DIALOG</see>
        /// or
        /// <see cref="MODE_DROPDOWN">MODE_DROPDOWN</see>
        /// and determines how the user will select choices from the spinner.
        /// </remarks>
        /// <param name="context">
        /// The Context the view is running in, through which it can
        /// access the current theme, resources, etc.
        /// </param>
        /// <param name="attrs">The attributes of the XML tag that is inflating the view.</param>
        /// <param name="defStyle">
        /// The default style to apply to this view. If 0, no style
        /// will be applied (beyond what is included in the theme). This may
        /// either be an attribute resource, whose value will be retrieved
        /// from the current theme, or an explicit style resource.
        /// </param>
        /// <param name="mode">Constant describing how the user will select choices from the spinner.
        ///     </param>
        /// <seealso cref="MODE_DIALOG">MODE_DIALOG</seealso>
        /// <seealso cref="MODE_DROPDOWN">MODE_DROPDOWN</seealso>
        public Spinner(android.content.Context context, android.util.AttributeSet attrs,
                       int defStyle, int mode) : base(context, attrs, defStyle)
        {
            // Only measure this many items to get a decent max width.
            android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                              .styleable.Spinner, defStyle, 0);
            if (mode == MODE_THEME)
            {
                mode = a.getInt([email protected]_spinnerMode, MODE_DIALOG);
            }
            switch (mode)
            {
            case MODE_DIALOG:
            {
                mPopup = new android.widget.Spinner.DialogPopup(this);
                break;
            }

            case MODE_DROPDOWN:
            {
                android.widget.Spinner.DropdownPopup popup = new android.widget.Spinner.DropdownPopup
                                                                 (this, context, attrs, defStyle);
                mDropDownWidth = a.getLayoutDimension([email protected]_dropDownWidth
                                                      , android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
                popup.setBackgroundDrawable(a.getDrawable([email protected]_popupBackground
                                                          ));
                int verticalOffset = a.getDimensionPixelOffset([email protected]_dropDownVerticalOffset
                                                               , 0);
                if (verticalOffset != 0)
                {
                    popup.setVerticalOffset(verticalOffset);
                }
                int horizontalOffset = a.getDimensionPixelOffset([email protected]_dropDownHorizontalOffset
                                                                 , 0);
                if (horizontalOffset != 0)
                {
                    popup.setHorizontalOffset(horizontalOffset);
                }
                mPopup = popup;
                break;
            }
            }
            mGravity = a.getInt([email protected]_gravity, android.view.Gravity
                                .CENTER);
            mPopup.setPromptText(java.lang.CharSequenceProxy.Wrap(a.getString([email protected]
                                                                              .styleable.Spinner_prompt)));
            a.recycle();
            // Base constructor can call setAdapter before we initialize mPopup.
            // Finish setting things up if this happened.
            if (mTempAdapter != null)
            {
                mPopup.setAdapter(mTempAdapter);
                mTempAdapter = null;
            }
        }
Example #2
0
		/// <summary>
		/// Construct a new spinner with the given context's theme, the supplied attribute set,
		/// and default style.
		/// </summary>
		/// <remarks>
		/// Construct a new spinner with the given context's theme, the supplied attribute set,
		/// and default style. <code>mode</code> may be one of
		/// <see cref="MODE_DIALOG">MODE_DIALOG</see>
		/// or
		/// <see cref="MODE_DROPDOWN">MODE_DROPDOWN</see>
		/// and determines how the user will select choices from the spinner.
		/// </remarks>
		/// <param name="context">
		/// The Context the view is running in, through which it can
		/// access the current theme, resources, etc.
		/// </param>
		/// <param name="attrs">The attributes of the XML tag that is inflating the view.</param>
		/// <param name="defStyle">
		/// The default style to apply to this view. If 0, no style
		/// will be applied (beyond what is included in the theme). This may
		/// either be an attribute resource, whose value will be retrieved
		/// from the current theme, or an explicit style resource.
		/// </param>
		/// <param name="mode">Constant describing how the user will select choices from the spinner.
		/// 	</param>
		/// <seealso cref="MODE_DIALOG">MODE_DIALOG</seealso>
		/// <seealso cref="MODE_DROPDOWN">MODE_DROPDOWN</seealso>
		public Spinner(android.content.Context context, android.util.AttributeSet attrs, 
			int defStyle, int mode) : base(context, attrs, defStyle)
		{
			// Only measure this many items to get a decent max width.
			android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
				.styleable.Spinner, defStyle, 0);
			if (mode == MODE_THEME)
			{
				mode = a.getInt([email protected]_spinnerMode, MODE_DIALOG);
			}
			switch (mode)
			{
				case MODE_DIALOG:
				{
					mPopup = new android.widget.Spinner.DialogPopup(this);
					break;
				}

				case MODE_DROPDOWN:
				{
					android.widget.Spinner.DropdownPopup popup = new android.widget.Spinner.DropdownPopup
						(this, context, attrs, defStyle);
					mDropDownWidth = a.getLayoutDimension([email protected]_dropDownWidth
						, android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
					popup.setBackgroundDrawable(a.getDrawable([email protected]_popupBackground
						));
					int verticalOffset = a.getDimensionPixelOffset([email protected]_dropDownVerticalOffset
						, 0);
					if (verticalOffset != 0)
					{
						popup.setVerticalOffset(verticalOffset);
					}
					int horizontalOffset = a.getDimensionPixelOffset([email protected]_dropDownHorizontalOffset
						, 0);
					if (horizontalOffset != 0)
					{
						popup.setHorizontalOffset(horizontalOffset);
					}
					mPopup = popup;
					break;
				}
			}
			mGravity = a.getInt([email protected]_gravity, android.view.Gravity
				.CENTER);
			mPopup.setPromptText(java.lang.CharSequenceProxy.Wrap(a.getString([email protected]
				.styleable.Spinner_prompt)));
			a.recycle();
			// Base constructor can call setAdapter before we initialize mPopup.
			// Finish setting things up if this happened.
			if (mTempAdapter != null)
			{
				mPopup.setAdapter(mTempAdapter);
				mTempAdapter = null;
			}
		}