예제 #1
0
        internal virtual int measureContentWidth(android.widget.SpinnerAdapter adapter, android.graphics.drawable.Drawable
                                                 background)
        {
            if (adapter == null)
            {
                return(0);
            }
            int width = 0;

            android.view.View itemView = null;
            int itemType         = 0;
            int widthMeasureSpec = android.view.View.MeasureSpec.makeMeasureSpec(0, android.view.View
                                                                                 .MeasureSpec.UNSPECIFIED);
            int heightMeasureSpec = android.view.View.MeasureSpec.makeMeasureSpec(0, android.view.View
                                                                                  .MeasureSpec.UNSPECIFIED);
            // Make sure the number of items we'll measure is capped. If it's a huge data set
            // with wildly varying sizes, oh well.
            int start = System.Math.Max(0, getSelectedItemPosition());
            int end   = System.Math.Min(adapter.getCount(), start + MAX_ITEMS_MEASURED);
            int count = end - start;

            start = System.Math.Max(0, start - (MAX_ITEMS_MEASURED - count));
            {
                for (int i = start; i < end; i++)
                {
                    int positionType = adapter.getItemViewType(i);
                    if (positionType != itemType)
                    {
                        itemType = positionType;
                        itemView = null;
                    }
                    itemView = adapter.getView(i, itemView, this);
                    if (itemView.getLayoutParams() == null)
                    {
                        itemView.setLayoutParams(new android.view.ViewGroup.LayoutParams(android.view.ViewGroup
                                                                                         .LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
                    }
                    itemView.measure(widthMeasureSpec, heightMeasureSpec);
                    width = System.Math.Max(width, itemView.getMeasuredWidth());
                }
            }
            // Add background padding to measured width
            if (background != null)
            {
                background.getPadding(mTempRect);
                width += mTempRect.left + mTempRect.right;
            }
            return(width);
        }
예제 #2
0
        public override int getNavigationItemCount()
        {
            switch (mActionView.getNavigationMode())
            {
            case NAVIGATION_MODE_TABS:
            {
                return(mTabs.size());
            }

            case NAVIGATION_MODE_LIST:
            {
                android.widget.SpinnerAdapter adapter = mActionView.getDropdownAdapter();
                return(adapter != null?adapter.getCount() : 0);
            }

            default:
            {
                return(0);
            }
            }
        }
예제 #3
0
 public virtual int getCount()
 {
     return(mAdapter == null ? 0 : mAdapter.getCount());
 }