Exemplo n.º 1
0
        private int measureContentWidth(android.widget.ListAdapter adapter)
        {
            // Menus don't tend to be long, so this is more sane than it looks.
            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);
            int count = adapter.getCount();

            {
                for (int i = 0; i < count; i++)
                {
                    int positionType = adapter.getItemViewType(i);
                    if (positionType != itemType)
                    {
                        itemType = positionType;
                        itemView = null;
                    }
                    if (mMeasureParent == null)
                    {
                        mMeasureParent = new android.widget.FrameLayout(mContext);
                    }
                    itemView = adapter.getView(i, itemView, mMeasureParent);
                    itemView.measure(widthMeasureSpec, heightMeasureSpec);
                    width = System.Math.Max(width, itemView.getMeasuredWidth());
                }
            }
            return(width);
        }
Exemplo n.º 2
0
 public virtual int getCount()
 {
     if (mAdapter != null)
     {
         return(getFootersCount() + getHeadersCount() + mAdapter.getCount());
     }
     else
     {
         return(getFootersCount() + getHeadersCount());
     }
 }