@Override public View getHeaderView(int i, View convertView, ViewGroup viewGroup) { Cursor cursor = getCursor(); HeaderViewHolder holder; if (convertView == null) { holder = new HeaderViewHolder(); convertView = li.inflate(R.layout.push_contact_selection_list_header, viewGroup, false); holder.text = (TextView) convertView.findViewById(R.id.text); convertView.setTag(holder); } else { holder = (HeaderViewHolder) convertView.getTag(); } cursor.moveToPosition(i); int type = cursor.getInt(cursor.getColumnIndexOrThrow(ContactsDatabase.TYPE_COLUMN)); if (type == ContactsDatabase.PUSH_TYPE) holder.text.setText(R.string.contact_selection_list__header_textsecure_users); else holder.text.setText(R.string.contact_selection_list__header_other); return convertView; }
@Override public View getHeaderView(int position, View convertView, ViewGroup parent) { HeaderViewHolder holder; if (convertView == null) { holder = new HeaderViewHolder(); convertView = inflater.inflate(R.layout.header, parent, false); holder.text = (TextView) convertView.findViewById(R.id.text); convertView.setTag(holder); } else { holder = (HeaderViewHolder) convertView.getTag(); } // set header text as first char in name AllEpisodesResponse episode = getItem(position); String airDate = episode.getAirdate(); String monthNumber = getMonthNumber(airDate); String day = getDay(airDate); String headerTextDate = null; if (monthNumber != null && day != null) { String monthName = getMonthName(monthNumber); if (monthName != null) { headerTextDate = monthName + " " + day; } } String headerText = null; if (headerTextDate != null && headerTextDate.length() > 0) { headerText = scheduleData.get(position).getDay() + ", " + headerTextDate; } else { headerText = scheduleData.get(position).getDay(); } holder.text.setText(headerText); return convertView; }
@Override public View getHeaderView(int position, View convertView, ViewGroup parent) { HeaderViewHolder holder; Cursor cursor = null; if (getCursor().getCount() > ConstsCore.ZERO_INT_VALUE) { cursor = (Cursor) getItem(position); } if (convertView == null) { holder = new HeaderViewHolder(); convertView = layoutInflater.inflate(R.layout.list_item_chat_sticky_header_date, parent, false); holder.headerTextView = (TextView) convertView.findViewById(R.id.header_date_textview); convertView.setTag(holder); } else { holder = (HeaderViewHolder) convertView.getTag(); } if (cursor != null) { long time = cursor.getLong(cursor.getColumnIndex(MessageTable.Cols.TIME)); holder.headerTextView.setText(DateUtils.longToMessageListHeaderDate(time)); } return convertView; }
@Override public View getHeaderView(int i, View convertView, ViewGroup viewGroup) { final Cursor c = getCursor(); final HeaderViewHolder holder; if (convertView == null) { holder = new HeaderViewHolder(); convertView = li.inflate(R.layout.push_contact_selection_list_header, viewGroup, false); holder.text = (TextView) convertView.findViewById(R.id.text); convertView.setTag(holder); } else { holder = (HeaderViewHolder) convertView.getTag(); } c.moveToPosition(i); final int type = c.getInt(c.getColumnIndexOrThrow(ContactsDatabase.TYPE_COLUMN)); final int headerTextRes; switch (type) { case 1: headerTextRes = R.string.contact_selection_list__header_textsecure_users; break; default: headerTextRes = R.string.contact_selection_list__header_other; break; } holder.text.setText(headerTextRes); return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { HeaderViewHolder holder; View view; if (convertView == null) { view = mInflater.inflate(R.layout.dialer_preferences, parent, false); holder = new HeaderViewHolder(); holder.title = (TextView) view.findViewById(R.id.title); holder.summary = (TextView) view.findViewById(R.id.summary); view.setTag(holder); } else { view = convertView; holder = (HeaderViewHolder) view.getTag(); } // All view fields must be updated every time, because the view may be recycled Header header = getItem(position); holder.title.setText(header.getTitle(getContext().getResources())); CharSequence summary = header.getSummary(getContext().getResources()); if (!TextUtils.isEmpty(summary)) { holder.summary.setVisibility(View.VISIBLE); holder.summary.setText(summary); } else { holder.summary.setVisibility(View.GONE); } return view; }
@Override public View getHeaderView(int position, View convertView, ViewGroup parent) { HeaderViewHolder holder; String headerText; long duration = 0; if (convertView == null) { holder = new HeaderViewHolder(); convertView = inflater.inflate(R.layout.history_list_header, parent, false); holder.text = (TextView) convertView.findViewById(R.id.history_list_header_text); holder.hours = (TextView) convertView.findViewById(R.id.history_list_header_hours); convertView.setTag(holder); } else { holder = (HeaderViewHolder) convertView.getTag(); } headerText = headerFormat.format(tataDays.get(position).getDate()); for (TataDay t : this.tataDays) { if (yearMonthFormat .format(t.getDate()) .equals(yearMonthFormat.format(tataDays.get(position).getDate()))) { duration += (t.getEnd().getTime() - t.getBegin().getTime()); } } holder.text.setText(headerText); holder.hours.setText(Utility.convertSecondsToHHMmSs(duration)); return convertView; }
@Override protected void bindHeader(HeaderViewHolder holder, int position) { super.bindHeader(holder, position); if (mTopic != null) { ImageLoader.loadImage(mTopic.getAvatarUrl(), holder.getImageView(R.id.iv_avatar)); holder.getTextView(R.id.tv_username).setText(mTopic.getAuther()); holder.getTextView(R.id.tv_create_time).setText(mTopic.getStatus()); holder.getTextView(R.id.tv_title).setText(mTopic.getTitle()); ((LJWebView) holder.getView(R.id.tv_content)).loadHtml(mTopic.getText()); } }
@Override public View getView(int position, View convertView, ViewGroup parent) { HeaderViewHolder holder; Header header = getItem(position); int headerType = getHeaderType(header); View view = null; if (convertView == null) { holder = new HeaderViewHolder(); switch (headerType) { case HEADER_TYPE_CATEGORY: view = new TextView(getContext(), null, android.R.attr.listSeparatorTextViewStyle); holder.title = (TextView) view; break; case HEADER_TYPE_NORMAL: view = mInflater.inflate(R.layout.preference_header_item, parent, false); holder.icon = (ImageView) view.findViewById(R.id.icon); holder.title = (TextView) view.findViewById(com.android.internal.R.id.title); holder.summary = (TextView) view.findViewById(com.android.internal.R.id.summary); break; } view.setTag(holder); } else { view = convertView; holder = (HeaderViewHolder) view.getTag(); } // All view fields must be updated every time, because the view may be recycled switch (headerType) { case HEADER_TYPE_CATEGORY: holder.title.setText(header.getTitle(getContext().getResources())); break; case HEADER_TYPE_NORMAL: holder.icon.setImageResource(header.iconRes); holder.title.setText(header.getTitle(getContext().getResources())); CharSequence summary = header.getSummary(getContext().getResources()); if (!TextUtils.isEmpty(summary)) { holder.summary.setVisibility(View.VISIBLE); holder.summary.setText(summary); } else { holder.summary.setVisibility(View.GONE); } break; } return view; }
@Override public View getHeaderView(int position, View convertView, ViewGroup parent) { HeaderViewHolder holder; if (convertView == null) { holder = new HeaderViewHolder(); convertView = inflater.inflate(R.layout.header, parent, false); holder.text = (TextView) convertView.findViewById(R.id.text1); convertView.setTag(holder); } else { holder = (HeaderViewHolder) convertView.getTag(); } // set header text as first char in name String headerText = "" + countries[position].subSequence(0, 1).charAt(0); holder.text.setText(headerText); return convertView; }
@Override public View getHeaderView(int position, View convertView, ViewGroup parent) { HeaderViewHolder holder; if (convertView == null) { holder = new HeaderViewHolder(); convertView = mInflater.inflate(R.layout.header, parent, false); holder.text = (TextView) convertView.findViewById(R.id.text1); convertView.setTag(holder); } else { holder = (HeaderViewHolder) convertView.getTag(); } // set header text as first char in name String headerText = Emails.get(position).Date; holder.text.setText(headerText); return convertView; }
public View getHeaderView(int position, View convertView, ViewGroup parent) { HeaderViewHolder holder; if (convertView == null) { holder = new HeaderViewHolder(); convertView = inflater.inflate(R.layout.list_row_header, parent, false); holder.text = (TextView) convertView.findViewById(R.id.headerText); convertView.setTag(holder); } else { holder = (HeaderViewHolder) convertView.getTag(); } // set header text as first char in name char headerChar = indexer.getSections()[indexer.getSectionForPosition(position)].toString().trim().charAt(0); String headerText = Character.toString(headerChar); holder.text.setText(headerText); return convertView; }
@Override public View getHeaderView(int position, View convertView, ViewGroup parent) { ShowInfo showInfo = this.getItem(position); HeaderViewHolder holder = null; if (convertView == null) { LayoutInflater inflater = LayoutInflater.from(getContext()); convertView = inflater.inflate(R.layout.show_list_header, null, false); holder = new HeaderViewHolder(); holder.tvShowListHeader = (TextView) convertView.findViewById(R.id.tvShowListHeader); convertView.setTag(holder); } else { holder = (HeaderViewHolder) convertView.getTag(); } holder.tvShowListHeader.setText(showInfo.getSchedule().toString()); return convertView; }
@Override public View getHeaderView(int position, View convertView, ViewGroup parent) { HeaderViewHolder holder; if (convertView == null) { holder = new HeaderViewHolder(); convertView = inflater.inflate(R.layout.item_listview_header, parent, false); holder.text = (TextView) convertView.findViewById(R.id.tv_fragment_lv_header); holder.background = (RelativeLayout) convertView.findViewById(R.id.rv_lv_header); convertView.setTag(holder); } else { holder = (HeaderViewHolder) convertView.getTag(); } // set header text as first char in name String headerText = "" + getItemTypeText(getItem(position)); holder.text.setText(headerText); return convertView; }
@Override public View getHeaderView(int position, View convertView, ViewGroup parent) { HeaderViewHolder holder; if (convertView == null) { holder = new HeaderViewHolder(); convertView = inflater.inflate(R.layout.header_all_appointment, parent, false); holder.text = (TextView) convertView.findViewById(R.id.slot); convertView.setTag(holder); } else { holder = (HeaderViewHolder) convertView.getTag(); } // set header text as first char in name String headerText = "" + UtilSingleInstance.getInstance() .getDateFormattedInStringFormatUsingLong(appointment.get(position).getDateTime()) .subSequence(7, 11); holder.text.setText(headerText); return convertView; }
@Override public void onBindViewHolder(BaseViewHolder holder, int position) { final UserDataHolder dataHolder = mDatas.get(position); final int itemViewType = dataHolder.getType(); switch (itemViewType) { case 0: HeaderViewHolder userViewHolder = (HeaderViewHolder) holder; userViewHolder.bind(mContext, dataHolder, position); break; case 1: ItemViewHolder itemViewHolder = (ItemViewHolder) holder; itemViewHolder.bind(mContext, dataHolder, position); break; case 2: DividerViewHolder dividerViewHolder = (DividerViewHolder) holder; dividerViewHolder.bind(mContext, dataHolder, position); break; default: break; } }
@Override public View getHeaderView(int position, View convertView, ViewGroup viewGroup) { HeaderViewHolder holder; if (convertView == null) { holder = new HeaderViewHolder(); convertView = mLayoutInflater.inflate(mHeaderLayoutResId, null); holder.headerTextView = (TextView) convertView.findViewById(R.id.title); convertView.setTag(holder); } else { holder = (HeaderViewHolder) convertView.getTag(); } // Check if this item falls within the subject or course list to determine header if (position < mSubjectSection.size()) { holder.headerTextView.setText(R.string.soc_sub_header); } else { holder.headerTextView.setText(R.string.soc_course_header); } return convertView; }
@SuppressWarnings("incomplete-switch") @Override public View getHeaderView(int position, View convertView, ViewGroup parent) { HeaderViewHolder holder; if (convertView == null) { convertView = inflater.inflate(R.layout.header, parent, false); holder = new HeaderViewHolder(); holder.text = (TextView) convertView.findViewById(R.id.text); holder.sumExpense = (TextView) convertView.findViewById(R.id.sum_expense); holder.sumIncome = (TextView) convertView.findViewById(R.id.sum_income); holder.sumTransfer = (TextView) convertView.findViewById(R.id.sum_transfer); holder.interimBalance = (TextView) convertView.findViewById(R.id.interim_balance); convertView.setTag(holder); } else { holder = (HeaderViewHolder) convertView.getTag(); } Cursor c = getCursor(); c.moveToPosition(position); int year = c.getInt( mAccount.grouping.equals(Grouping.WEEK) ? columnIndexYearOfWeekStart : columnIndexYear); int second = -1; if (mGroupingCursor != null) { mGroupingCursor.moveToFirst(); // no grouping, we need the first and only row if (mAccount.grouping.equals(Grouping.NONE)) { fillSums(holder, mGroupingCursor); } else { traverseCursor: while (!mGroupingCursor.isAfterLast()) { if (mGroupingCursor.getInt(columnIndexGroupYear) == year) { switch (mAccount.grouping) { case YEAR: fillSums(holder, mGroupingCursor); break traverseCursor; case DAY: second = c.getInt(columnIndexDay); if (mGroupingCursor.getInt(columnIndexGroupSecond) != second) break; else { fillSums(holder, mGroupingCursor); break traverseCursor; } case MONTH: second = c.getInt(columnIndexMonth); if (mGroupingCursor.getInt(columnIndexGroupSecond) != second) break; else { fillSums(holder, mGroupingCursor); break traverseCursor; } case WEEK: second = c.getInt(columnIndexWeek); if (mGroupingCursor.getInt(columnIndexGroupSecond) != second) break; else { fillSums(holder, mGroupingCursor); break traverseCursor; } } } mGroupingCursor.moveToNext(); } } if (!mGroupingCursor.isAfterLast()) mappedCategoriesPerGroup.put( position, mGroupingCursor.getInt(columnIndexGroupMappedCategories) > 0); } holder.text.setText(mAccount.grouping.getDisplayTitle(getActivity(), year, second, c)); // holder.text.setText(mAccount.grouping.getDisplayTitle(getActivity(), year, second, // mAccount.grouping.equals(Grouping.WEEK)?this_year_of_week_start:this_year, // this_week,this_day)); return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { switch (getItemViewType(position)) { case ITEM_TYPE_VIEW: { convertView = (ItemListItem) inflater.inflate(R.layout.item_listitem_view, parent, false); ViewHolder holder = new ViewHolder(); holder.text1 = (TextView) convertView.findViewById(android.R.id.text1); holder.text2 = (TextView) convertView.findViewById(android.R.id.text2); holder.text3 = (TextView) convertView.findViewById(R.id.text3); holder.icon1 = (ImageView) convertView.findViewById(android.R.id.icon1); holder.flip = (FlipImageView) convertView.findViewById(android.R.id.icon1); holder.icon2 = (ImageView) convertView.findViewById(android.R.id.icon2); holder.icon_chain_bottom = (ImageView) convertView.findViewById(R.id.icon_chain_bottom); holder.icon_chain_top = (ImageView) convertView.findViewById(R.id.icon_chain_top); convertView.setTag(holder); break; } case ITEM_TYPE_EDIT: { convertView = (ItemListItem) inflater.inflate(R.layout.item_listitem_equippeditem, parent, false); ViewHolder holder = new ViewHolder(); holder.text1 = (TextView) convertView.findViewById(android.R.id.text1); holder.text2 = (TextView) convertView.findViewById(android.R.id.text2); holder.text3 = (TextView) convertView.findViewById(R.id.text3); holder.icon1 = (ImageView) convertView.findViewById(android.R.id.icon1); holder.icon2 = (ImageView) convertView.findViewById(android.R.id.icon2); holder.icon_chain_bottom = (ImageView) convertView.findViewById(R.id.icon_chain_bottom); holder.icon_chain_top = (ImageView) convertView.findViewById(R.id.icon_chain_top); convertView.setTag(holder); break; } case ITEM_TYPE_SEEK: { convertView = (ViewGroup) inflater.inflate(R.layout.item_listitem_seek, parent, false); SeekViewHolder viewHolder = new SeekViewHolder(); viewHolder.seek = (SeekBarEx) convertView.findViewById(R.id.wheel); viewHolder.text = (TextView) convertView.findViewById(R.id.wheel_label); viewHolder.value = (Button) convertView.findViewById(R.id.wheel_value); convertView.setTag(viewHolder); break; } case ITEM_TYPE_COMBAT_TALENT: case ITEM_TYPE_SIMPLE_TALENT: { convertView = inflater.inflate(R.layout.item_listitem_talent, parent, false); TalentViewHolder holder = new TalentViewHolder(); // name holder.text1 = (TextView) convertView.findViewById(R.id.talent_list_item_text1); // be holder.text2 = (TextView) convertView.findViewById(R.id.talent_list_item_text2); // probe holder.text3 = (TextView) convertView.findViewById(R.id.talent_list_item_text3); // value / at holder.text4 = (TextView) convertView.findViewById(R.id.talent_list_item_text4); // pa holder.text5 = (TextView) convertView.findViewById(R.id.talent_list_item_text5); holder.indicator = (ImageView) convertView.findViewById(R.id.talent_list_item_indicator); convertView.setTag(holder); break; } case ITEM_TYPE_MODIFIER: { // We need the layoutinflater to pick up the view from xml // Pick up the TwoLineListItem defined in the xml file convertView = inflater.inflate(R.layout.item_listitem_modifier, parent, false); ModifierViewHolder holder = new ModifierViewHolder(); holder.text1 = (TextView) convertView.findViewById(android.R.id.text1); holder.text2 = (TextView) convertView.findViewById(android.R.id.text2); holder.flip = (FlipImageView) convertView.findViewById(android.R.id.icon1); holder.active = (CheckBox) convertView.findViewById(R.id.active); convertView.setTag(holder); break; } case ITEM_TYPE_HEADER: { convertView = inflater.inflate(R.layout.item_listitem_header, parent, false); HeaderViewHolder holder = new HeaderViewHolder(); holder.text1 = (TextView) convertView.findViewById(android.R.id.text1); convertView.setTag(holder); break; } case ITEM_TYPE_NOTES: { convertView = inflater.inflate(R.layout.item_listitem_event, parent, false); EventViewHolder holder = new EventViewHolder(); holder.text1 = (TextView) convertView.findViewById(android.R.id.text1); holder.text2 = (TextView) convertView.findViewById(android.R.id.text2); holder.text3 = (TextView) convertView.findViewById(R.id.text3); holder.flip = (FlipImageView) convertView.findViewById(android.R.id.icon1); holder.icon2 = (ImageView) convertView.findViewById(android.R.id.icon2); convertView.setTag(holder); break; } case ITEM_TYPE_PURSE: convertView = inflater.inflate(R.layout.item_listitem_purse, parent, false); PurseViewHolder holder = new PurseViewHolder(); holder.currencySpinner = (Spinner) convertView.findViewById(R.id.sp_currency); holder.header = (TextView) convertView.findViewById(R.id.tv_currency_header); holder.picker = new NumberPicker[4]; holder.picker[0] = (NumberPicker) convertView.findViewById(R.id.popup_purse_dukat); holder.picker[1] = (NumberPicker) convertView.findViewById(R.id.popup_purse_silver); holder.picker[2] = (NumberPicker) convertView.findViewById(R.id.popup_purse_heller); holder.picker[3] = (NumberPicker) convertView.findViewById(R.id.popup_purse_kreuzer); holder.labels = new TextView[4]; holder.labels[0] = (TextView) convertView.findViewById(R.id.tv_currency1); holder.labels[1] = (TextView) convertView.findViewById(R.id.tv_currency2); holder.labels[2] = (TextView) convertView.findViewById(R.id.tv_currency3); holder.labels[3] = (TextView) convertView.findViewById(R.id.tv_currency4); convertView.setTag(holder); break; } } FlippableViewHolder.prepare(position, convertView, (ListView) parent); Listable item = getItem(position); if (item instanceof EquippedItem) { convertView = prepareView((EquippedItem) item, position, convertView, parent); } else if (item instanceof Attribute) { convertView = prepareView((Attribute) item, position, convertView, parent); } else if (item instanceof Talent) { convertView = prepareView((Talent) item, position, convertView, parent); } else if (item instanceof Spell) { convertView = prepareView((Spell) item, position, convertView, parent); } else if (item instanceof Art) { convertView = prepareView((Art) item, position, convertView, parent); } else if (item instanceof Modificator) { convertView = prepareView((Modificator) item, position, convertView, parent); } else if (item instanceof HeaderListItem) { convertView = prepareView((HeaderListItem) item, position, convertView, parent); } else if (item instanceof FileListable) { convertView = prepareView((FileListable) item, position, convertView, parent); } else if (item instanceof NotesItem) { convertView = prepareView((NotesItem) item, position, convertView, parent); } else if (item instanceof PurseListable) { convertView = prepareView((PurseListable) item, position, convertView, parent); } if (item instanceof Markable) { Util.applyRowStyle((Markable) item, convertView, position); } else { Util.applyRowStyle(convertView, position); } return convertView; }
/** * Gets and inflates the View at the specified position * * <p>Depending on if the item is a normal item or a header, it will set the contained Views * accordingly * * <p>This method also checks to see if a View of the same type was already shown before so it can * reuse the View * * @param position * @param convertView * @param parent */ @Override public View getView(int position, View convertView, ViewGroup parent) { // Get the drawer item NavigationDrawerItem item = this.getItem(position); // Check if the item is a header if (item.isHeader()) { // Cast to the header type HeaderDrawerItem headerItem = (HeaderDrawerItem) item; // See if the view is being reused HeaderViewHolder viewHolder; if (convertView == null) { // The view has not been shown yet, so find the necessary views and store them in a // ViewHolder viewHolder = new HeaderViewHolder(); // Inflate the layout LayoutInflater inflater = LayoutInflater.from(this.mContext); convertView = inflater.inflate(R.layout.navigation_drawer_header_item, parent, false); // Store the views viewHolder.textView = (TextView) convertView.findViewById(R.id.navigation_drawer_item_text); viewHolder.position = position; convertView.setTag(viewHolder); } else { // The view has already been shown, so reuse it viewHolder = (HeaderViewHolder) convertView.getTag(); } // Set the text viewHolder.textView.setText(headerItem.getText()); return convertView; } else { // Cast to the normal type NormalDrawerItem normalItem = (NormalDrawerItem) item; // See if the view is being reused NormalViewHolder viewHolder; if (convertView == null) { // The view has not been shown yet, so find the necessary views and store them in a // ViewHolder viewHolder = new NormalViewHolder(); // Inflate the layout LayoutInflater inflater = LayoutInflater.from(this.mContext); convertView = inflater.inflate(R.layout.navigation_drawer_normal_item, parent, false); // Store the views viewHolder.imageView = (ImageView) convertView.findViewById(R.id.navigation_drawer_item_icon); viewHolder.textView = (TextView) convertView.findViewById(R.id.navigation_drawer_item_text); viewHolder.position = position; convertView.setTag(viewHolder); } else { // The view has already been shown, so reuse it viewHolder = (NormalViewHolder) convertView.getTag(); } // Set the icon and the text viewHolder.imageView.setImageDrawable(normalItem.getDrawable()); viewHolder.textView.setText(normalItem.getText()); return convertView; } }
@Override public View getView(int position, View convertView, ViewGroup parent) { HeaderViewHolder holder; Header header = getItem(position); int headerType = getHeaderType(header); View view = null; if (convertView == null || headerType == HEADER_TYPE_SWITCH) { holder = new HeaderViewHolder(); switch (headerType) { case HEADER_TYPE_CATEGORY: view = new TextView(getContext(), null, android.R.attr.listSeparatorTextViewStyle); holder.title = (TextView) view; break; case HEADER_TYPE_SWITCH: view = mInflater.inflate(R.layout.preference_header_switch_item, parent, false); holder.icon = (ImageView) view.findViewById(R.id.icon); holder.title = (TextView) view.findViewById(com.android.internal.R.id.title); holder.summary = (TextView) view.findViewById(com.android.internal.R.id.summary); holder.switch_ = (Switch) view.findViewById(R.id.switchWidget); break; case HEADER_TYPE_NORMAL: view = mInflater.inflate(R.layout.preference_header_item, parent, false); holder.icon = (ImageView) view.findViewById(R.id.icon); holder.title = (TextView) view.findViewById(com.android.internal.R.id.title); holder.summary = (TextView) view.findViewById(com.android.internal.R.id.summary); break; } view.setTag(holder); } else { view = convertView; holder = (HeaderViewHolder) view.getTag(); } // All view fields must be updated every time, because the view may be recycled switch (headerType) { case HEADER_TYPE_CATEGORY: holder.title.setText(header.getTitle(getContext().getResources())); break; case HEADER_TYPE_SWITCH: // Would need a different treatment if the main menu had more switches if (header.id == R.id.wifi_settings) { mWifiEnabler.setSwitch(holder.switch_); } else if (header.id == R.id.bluetooth_settings) { mBluetoothEnabler.setSwitch(holder.switch_); } else if (header.id == R.id.profiles_settings) { mProfileEnabler.setSwitch(holder.switch_); } else if (header.id == R.id.trds_settings) { mTRDSSwitch = (Switch) view.findViewById(R.id.switchWidget); mTRDSEnabler.setSwitch(holder.switch_); } // No break, fall through on purpose to update common fields // $FALL-THROUGH$ case HEADER_TYPE_NORMAL: if (header.extras != null && header.extras.containsKey(ManageAccountsSettings.KEY_ACCOUNT_TYPE)) { String accType = header.extras.getString(ManageAccountsSettings.KEY_ACCOUNT_TYPE); ViewGroup.LayoutParams lp = holder.icon.getLayoutParams(); lp.width = getContext().getResources().getDimensionPixelSize(R.dimen.header_icon_width); lp.height = lp.width; holder.icon.setLayoutParams(lp); Drawable icon = mAuthHelper.getDrawableForType(getContext(), accType); holder.icon.setImageDrawable(icon); } else { holder.icon.setImageResource(header.iconRes); } holder.title.setText(header.getTitle(getContext().getResources())); CharSequence summary = header.getSummary(getContext().getResources()); if (!TextUtils.isEmpty(summary)) { holder.summary.setVisibility(View.VISIBLE); holder.summary.setText(summary); } else { holder.summary.setVisibility(View.GONE); } break; } return view; }
@Override public View getView(int position, View convertView, ViewGroup parent) { HeaderViewHolder holder; Header header = getItem(position); int headerType = getHeaderType(header); View view; if (convertView == null) { holder = new HeaderViewHolder(); LinearLayout flview; flview = new LinearLayout(context); flview.setLayoutParams( new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Simple.DP(56))); if (headerType == HEADER_TYPE_NORMAL) { holder.icon = new ImageSmartView(context); Simple.setPadding(holder.icon, 24, 12, 0, 12); flview.addView( holder.icon, new LinearLayout.LayoutParams(Simple.DP(56), ViewGroup.LayoutParams.MATCH_PARENT)); } holder.title = new TextView(context); holder.title.setGravity(Gravity.CENTER_VERTICAL); Simple.setPadding(holder.title, 16, 0, 0, 0); flview.addView( holder.title, new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, Gravity.START)); if (headerType == HEADER_TYPE_NORMAL) { Simple.setTextSize(holder.title, 17f); holder.title.setTextColor(0xff000000); } if (headerType == HEADER_TYPE_CATEGORY) { Simple.setTextSize(holder.title, 16f); Simple.setPadding(holder.title, 32, 0, 0, 0); flview.setBackgroundColor(0xcccccccc); } flview.setTag(holder); view = flview; } else { view = convertView; holder = (HeaderViewHolder) view.getTag(); } // // All view fields must be updated every time, // because the view may be recycled. // if (holder.icon != null) { if (header.iconRes != 0) { holder.icon.setImageResource(header.iconRes); } else { // // Check if we have a webapp here. // if (header.fragmentArguments != null) { String webappname = header.fragmentArguments.getString("webappname"); if (webappname != null) { if ((holder.icon.getTag() == null) || !Simple.equals((String) holder.icon.getTag(), webappname)) { holder.icon.setTag(webappname); holder.icon.setImageResource(webappname); } } } } } holder.title.setText(header.getTitle(getContext().getResources())); return view; }