@Override public View getView(int position, View convertView, ViewGroup parent) { if (DEBUG) { Log.d(LOG_TAG, String.format("getView: %s, reused: %s", position, convertView == null)); } // Header (negative positions will throw an ArrayIndexOutOfBoundsException) int numHeadersAndPlaceholders = getHeadersCount() * mNumColumns; if (position < numHeadersAndPlaceholders) { View headerViewContainer = mHeaderViewInfos.get(position / mNumColumns).viewContainer; if (position % mNumColumns == 0) { return headerViewContainer; } else { if (convertView == null) { convertView = new View(parent.getContext()); } // We need to do this because GridView uses the height of the last item // in a row to determine the height for the entire row. convertView.setVisibility(View.INVISIBLE); convertView.setMinimumHeight(headerViewContainer.getHeight()); return convertView; } } // Adapter final int adjPosition = position - numHeadersAndPlaceholders; int adapterCount = 0; if (mAdapter != null) { adapterCount = getAdapterAndPlaceHolderCount(); if (adjPosition < adapterCount) { if (adjPosition < mAdapter.getCount()) { return mAdapter.getView(adjPosition, convertView, parent); } else { if (convertView == null) { convertView = new View(parent.getContext()); } convertView.setVisibility(View.INVISIBLE); convertView.setMinimumHeight(mRowHeight); return convertView; } } } // Footer final int footerPosition = adjPosition - adapterCount; if (footerPosition < getCount()) { View footViewContainer = mFooterViewInfos.get(footerPosition / mNumColumns).viewContainer; if (position % mNumColumns == 0) { return footViewContainer; } else { if (convertView == null) { convertView = new View(parent.getContext()); } // We need to do this because GridView uses the height of the last item // in a row to determine the height for the entire row. convertView.setVisibility(View.INVISIBLE); convertView.setMinimumHeight(footViewContainer.getHeight()); return convertView; } } throw new ArrayIndexOutOfBoundsException(position); }
private void initView() { // TODO Auto-generated method stub // ListVIew mAdapter = new SNoticeListAdapter(getActivity(), mList); // 填充listview头尾空间 View view1 = new View(getActivity()); view1.setMinimumHeight((int) getResources().getDimension(R.dimen.view_smallsmallsmall_margin)); mNoticeListView.addHeaderView(view1); View view2 = new View(getActivity()); view2.setMinimumHeight((int) getResources().getDimension(R.dimen.view_smallsmallsmall_margin)); mNoticeListView.addFooterView(view2); mNoticeListView.setAdapter(mAdapter); // PullToRefreshView mPullToRefreshView.setOnHeaderRefreshListener( new OnHeaderRefreshListener() { @Override public void onHeaderRefresh(PullToRefreshView view) { // TODO Auto-generated method stub mCurrentPage = 0; postNoticeList(); ((SystemMessageActivity) getActivity()).postUnreadNum(); } }); mPullToRefreshView.setOnFooterRefreshListener( new OnFooterRefreshListener() { @Override public void onFooterRefresh(PullToRefreshView view) { // TODO Auto-generated method stub postNoticeList(); ((SystemMessageActivity) getActivity()).postUnreadNum(); } }); noticeService = new NoticeService(getActivity()) { @Override public void getBBSpaceDataFailure() { // TODO Auto-generated method stub mPullToRefreshView.onHeaderRefreshComplete(); mPullToRefreshView.onFooterRefreshComplete(); progress.setVisibility(View.GONE); } @Override public void getBBSpaceData(String content) { // TODO Auto-generated method stub parseSNoticeList(content); } }; }
@Override public View createTabContent(final String tag) { final View v = new View(mContext); v.setMinimumWidth(0); v.setMinimumHeight(0); return v; }
public View createTabContent(String paramString) { View localView = new View(this.mContext); localView.setMinimumWidth(0); localView.setMinimumHeight(0); return localView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { // Header (negative positions will throw an // ArrayIndexOutOfBoundsException) int numHeadersAndPlaceholders = getHeadersCount() * mNumColumns; if (position < numHeadersAndPlaceholders) { View headerViewContainer = mHeaderViewInfos.get(position / mNumColumns).viewContainer; if (position % mNumColumns == 0) { return headerViewContainer; } else { if (convertView == null) { convertView = new View(parent.getContext()); } // We need to do this because GridView uses the height of // the last item // in a row to determine the height for the entire row. convertView.setVisibility(View.INVISIBLE); convertView.setMinimumHeight(headerViewContainer.getHeight()); return convertView; } } // Adapter final int adjPosition = position - numHeadersAndPlaceholders; int adapterCount = 0; if (mAdapter != null) { adapterCount = mAdapter.getCount(); if (adjPosition < adapterCount) { return mAdapter.getView(adjPosition, convertView, parent); } } throw new ArrayIndexOutOfBoundsException(position); }
/** apply minimum Height in view */ public static void applyMinHeight(View view, DynamicProperty property) { if (view != null) { if (property.type == DynamicProperty.TYPE.DIMEN) { view.setMinimumHeight(property.getValueInt()); } } }
@Override public View getView(int position, View convertView, ViewGroup parent) { PromptListItem item = getItem(position); ViewHolder viewHolder = null; if (convertView == null) { int resourceId = mResourceId; if (item.isGroup) { resourceId = R.layout.list_item_header; } convertView = mInflater.inflate(resourceId, null); convertView.setMinimumHeight(mMinRowSize); TextView tv = (TextView) convertView.findViewById(android.R.id.text1); viewHolder = new ViewHolder( tv, tv.getPaddingLeft(), tv.getPaddingRight(), tv.getPaddingTop(), tv.getPaddingBottom()); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } viewHolder.textView.setText(item.label); maybeUpdateCheckedState(position, item, viewHolder); maybeUpdateIcon(item, viewHolder.textView); return convertView; }
@Override public View getDropDownView(int position, View convertView, ViewGroup parent) { View item = inflater.inflate(R.layout.time_settings_dropdown_item, null); item.setMinimumHeight(60); if (position >= times.size()) { ((CheckedTextView) item).setText(getText(R.string.customTime)); } else { SpannableString ss = new SpannableString( times.get(position) + " " + getString(R.string.min) + " (+" + increments.get(position) + getString(R.string.secPerMove) + ")"); ss.setSpan(new ForegroundColorSpan(0xFF000000), 0, 6, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); ss.setSpan( new ForegroundColorSpan(0xFF666666), 6, ss.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); ((CheckedTextView) item).setText(ss); } return item; }
public void updatePadding(CardViewDelegate cardViewDelegate) { Rect rect = new Rect(); getShadowBackground(cardViewDelegate).getMaxShadowAndCornerPadding(rect); ((View) cardViewDelegate) .setMinimumHeight((int) Math.ceil((double) getMinHeight(cardViewDelegate))); ((View) cardViewDelegate) .setMinimumWidth((int) Math.ceil((double) getMinWidth(cardViewDelegate))); cardViewDelegate.setShadowPadding(rect.left, rect.top, rect.right, rect.bottom); }
@Override public View getView(int position, View convertView, ViewGroup parent) { View item = getLayoutInflater().inflate(R.layout.grid_item_layout, null); item.setPadding(0, 50, 0, 40); GridItemContact current = gridItemerAbout.get(position); TextView label = (TextView) item.findViewById(R.id.item_label); label.setText(current.text); label.setCompoundDrawables(null, current.image, null, null); label.setCompoundDrawablePadding(32); item.setMinimumHeight(300); return item; }
/** Set our margins and title area height proportionally to the available display size */ @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int parentWidth = MeasureSpec.getSize(widthMeasureSpec); int parentHeight = MeasureSpec.getSize(heightMeasureSpec); final Resources resources = getContext().getResources(); float titleHeight = resources.getFraction(R.dimen.setup_title_height, 1, 1); float sideMargin = resources.getFraction(R.dimen.setup_border_width, 1, 1); int bottom = resources.getDimensionPixelSize(R.dimen.setup_margin_bottom); setPaddingRelative( (int) (parentWidth * sideMargin), 0, (int) (parentWidth * sideMargin), bottom); View title = findViewById(R.id.title_area); if (title != null) { title.setMinimumHeight((int) (parentHeight * titleHeight)); } super.onMeasure(widthMeasureSpec, heightMeasureSpec); }
@Override public View getView(int i, View view, ViewGroup viewGroup) { if (view == null) { // inflates only when it is necessary.it is correct style of writing such as // code. view = View.inflate(context, R.layout.activity_profile_list_view_item, null); } TextView playListName = (TextView) view.findViewById(R.id.activity_profile_name); playListName.setText(playLists.get(i).getName()); final int index = i; TextView playList = (TextView) view.findViewById(R.id.playList_hyper); playList.setVisibility(View.INVISIBLE); playListName.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) {} }); view.setMinimumHeight(125); return view; }
@Override public View getView(int position, View convertView, ViewGroup container) { Log.d("ApplicationAdapter", "getView"); ViewHolder viewHolder; if (convertView == null) { LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.app_model, null); viewHolder = new ViewHolder(); viewHolder.appname = (TextView) convertView.findViewById(R.id.label); viewHolder.appicon = (ImageView) convertView.findViewById(R.id.icon); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } AppInfo ai = mInfos.get(position); viewHolder.appname.setText(ai.label); viewHolder.appicon.setImageDrawable(ai.icon); convertView.setMinimumHeight(gridView.getHeight() / mRow); return convertView; }
public View createTabContent(String tag) { View v = new View(mContext); v.setMinimumWidth(0); v.setMinimumHeight(0); return v; }