public virtual android.view.View getView(int position, android.view.View convertView , android.view.ViewGroup parent) { // Header (negative positions will throw an ArrayIndexOutOfBoundsException) int numHeaders = getHeadersCount(); if (position < numHeaders) { return(mHeaderViewInfos.get(position).view); } // Adapter int adjPosition = position - numHeaders; int adapterCount = 0; if (mAdapter != null) { adapterCount = mAdapter.getCount(); if (adjPosition < adapterCount) { return(mAdapter.getView(adjPosition, convertView, parent)); } } // Footer (off-limits positions will throw an ArrayIndexOutOfBoundsException) return(mFooterViewInfos.get(adjPosition - adapterCount).view); }
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); }