Ejemplo n.º 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;
            }
        }
Ejemplo n.º 2
0
 /// <summary>Creates a new set of layout parameters.</summary>
 /// <remarks>
 /// Creates a new set of layout parameters. The values are extracted from
 /// the supplied attributes set and context. The XML attributes mapped
 /// to this set of layout parameters are:
 /// <ul>
 /// <li><code>layout_x</code>: the X location of the child</li>
 /// <li><code>layout_y</code>: the Y location of the child</li>
 /// <li>All the XML attributes from
 /// <see cref="android.view.ViewGroup.LayoutParams">android.view.ViewGroup.LayoutParams
 ///     </see>
 /// </li>
 /// </ul>
 /// </remarks>
 /// <param name="c">the application environment</param>
 /// <param name="attrs">
 /// the set of attributes from which to extract the layout
 /// parameters values
 /// </param>
 public LayoutParams(android.content.Context c, android.util.AttributeSet attrs) :
     base(c, attrs)
 {
     android.content.res.TypedArray a = c.obtainStyledAttributes(attrs, [email protected]
                                                                 .styleable.AbsoluteLayout_Layout);
     x = a.getDimensionPixelOffset([email protected]_Layout_layout_x
                                   , 0);
     y = a.getDimensionPixelOffset([email protected]_Layout_layout_y
                                   , 0);
     a.recycle();
 }
Ejemplo n.º 3
0
 /// <summary>Subclasses override this to parse custom subelements.</summary>
 /// <remarks>
 /// Subclasses override this to parse custom subelements.
 /// If you handle it, return true, else return <em>super.inflateTag(...)</em>.
 /// </remarks>
 protected internal virtual bool inflateTag(string name, android.content.res.Resources
                                            r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs)
 {
     if ("padding".Equals(name))
     {
         android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
                                                               styleable.ShapeDrawablePadding);
         setPadding(a.getDimensionPixelOffset([email protected]_left
                                              , 0), a.getDimensionPixelOffset([email protected]_top
                                                                              , 0), a.getDimensionPixelOffset([email protected]_right
                                                                                                              , 0), a.getDimensionPixelOffset([email protected]_bottom
                                                                                                                                              , 0));
         a.recycle();
         return(true);
     }
     return(false);
 }
Ejemplo n.º 4
0
        public AbsSeekBar(android.content.Context context, android.util.AttributeSet attrs
                          , int defStyle) : base(context, attrs, defStyle)
        {
            android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                              .styleable.SeekBar, defStyle, 0);
            android.graphics.drawable.Drawable thumb = a.getDrawable([email protected]
                                                                     .SeekBar_thumb);
            setThumb(thumb);
            // will guess mThumbOffset if thumb != null...
            // ...but allow layout to override this
            int thumbOffset = a.getDimensionPixelOffset([email protected]_thumbOffset
                                                        , getThumbOffset());

            setThumbOffset(thumbOffset);
            a.recycle();
            a = context.obtainStyledAttributes(attrs, [email protected], 0,
                                               0);
            mDisabledAlpha = a.getFloat([email protected]_disabledAlpha, 0.5f
                                        );
            a.recycle();
            mScaledTouchSlop = android.view.ViewConfiguration.get(context).getScaledTouchSlop
                                   ();
        }
Ejemplo n.º 5
0
        public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser
                                     parser, android.util.AttributeSet attrs)
        {
            base.inflate(r, parser, attrs);
            int type;

            android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
                                                                  styleable.LayerDrawable);
            mOpacityOverride = a.getInt([email protected]_opacity,
                                        android.graphics.PixelFormat.UNKNOWN);
            a.recycle();
            int innerDepth = parser.getDepth() + 1;
            int depth;

            while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT &&
                   ((depth = parser.getDepth()) >= innerDepth || type != org.xmlpull.v1.XmlPullParserClass.END_TAG
                   ))
            {
                if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
                {
                    continue;
                }
                if (depth > innerDepth || !parser.getName().Equals("item"))
                {
                    continue;
                }
                a = r.obtainAttributes(attrs, [email protected]);
                int left = a.getDimensionPixelOffset([email protected]_left
                                                     , 0);
                int top = a.getDimensionPixelOffset([email protected]_top
                                                    , 0);
                int right = a.getDimensionPixelOffset([email protected]_right
                                                      , 0);
                int bottom = a.getDimensionPixelOffset([email protected]_bottom
                                                       , 0);
                int drawableRes = a.getResourceId([email protected]_drawable
                                                  , 0);
                int id = a.getResourceId([email protected]_id, android.view.View
                                         .NO_ID);
                a.recycle();
                android.graphics.drawable.Drawable dr;
                if (drawableRes != 0)
                {
                    dr = r.getDrawable(drawableRes);
                }
                else
                {
                    while ((type = parser.next()) == org.xmlpull.v1.XmlPullParserClass.TEXT)
                    {
                    }
                    if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
                    {
                        throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
                                                                        ": <item> tag requires a 'drawable' attribute or " + "child tag defining a drawable"
                                                                        );
                    }
                    dr = android.graphics.drawable.Drawable.createFromXmlInner(r, parser, attrs);
                }
                addLayer(dr, id, left, top, right, bottom);
            }
            ensurePadding();
            onStateChange(getState());
        }