@Override public View getView(final int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub index = position; final ArrayList<Info> list = (ArrayList<Info>) mList.get(position); convertView = mInflater.inflate(R.layout.buy_jc_main_view_list_item, null); final ViewHolder holder = new ViewHolder(); holder.btn = (Button) convertView.findViewById(R.id.buy_jc_main_view_list_item_btn); holder.layout = (LinearLayout) convertView.findViewById(R.id.buy_jc_main_view_list_item_linearLayout); holder.btn.setBackgroundResource(R.drawable.buy_jc_btn_close); if (list.size() == 0) { holder.btn.setVisibility(Button.GONE); } else { isOpen(list, holder); holder.btn.setText( list.get(0).getTime() + " " + list.size() + context.getString(R.string.jc_main_btn_text)); holder.btn.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub list.get(0).isOpen = !list.get(0).isOpen; isOpen(list, holder); } }); for (Info info : list) { holder.layout.addView(addLayout(info)); } } return convertView; }
// populates the view with input data @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; // if (convertView == null) { LayoutInflater inflater = getLayoutInflater(); convertView = inflater.inflate(R.layout.activity_chat_singlemessage, parent, false); holder = new ViewHolder(); holder.layout = (LinearLayout) convertView.findViewById(R.id.singleMessageContainer); holder.title = (TextView) holder.layout.findViewById(R.id.singleMessage); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } if (!messages.isEmpty()) { if (messages.get(position).get("direction").equals("0")) { // msg bubble onto right holder.layout.setGravity(Gravity.RIGHT); holder.title.setBackgroundResource(R.drawable.bubble_b); } else { // msg bubble onto left holder.layout.setGravity(Gravity.LEFT); holder.title.setBackgroundResource(R.drawable.bubble_a); } holder.title.setText((String) messages.get(position).get("body")); } return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = inflater.inflate(R.layout.all_patient_appo_item, parent, false); holder.layout = (RelativeLayout) convertView.findViewById(R.id.layout); holder.date = (TextView) convertView.findViewById(R.id.date); holder.visitType = (TextView) convertView.findViewById(R.id.visitType); holder.time = (TextView) convertView.findViewById(R.id.time); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } final int pos = position; holder.date.setText( UtilSingleInstance.getInstance() .getOnlyDateFormattedInStringFormatUsingLong(appointment.get(position).getDateTime())); holder.time.setText( UtilSingleInstance.getInstance() .getOnlyTimeFormattedInStringFormatUsingLong(appointment.get(position).getDateTime())); holder.visitType.setText( UtilSingleInstance.getUserVisitType(appointment.get(position).getVisitType())); // holder.time.setText(appointment.get(position).getBookTime()); return convertView; }
public View getViewSeparator(int position, View convertView, ViewGroup parent) { View v = convertView; ViewHolder holder; /* convertView may be a recycled view but we must recreate it * if it does not correspond to a separator view. */ boolean b_createView = true; if (v != null) { holder = (ViewHolder) v.getTag(); if (holder.viewType == VIEW_SEPARATOR) b_createView = false; } if (b_createView) { LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = inflater.inflate(R.layout.audio_browser_separator, parent, false); holder = new ViewHolder(); holder.layout = v.findViewById(R.id.layout_item); holder.title = (TextView) v.findViewById(R.id.title); holder.viewType = VIEW_SEPARATOR; v.setTag(holder); } else holder = (ViewHolder) v.getTag(); ListItem item = getItem(position); holder.title.setText(item.mTitle); return v; }
public View getViewMedia(int position, View convertView, ViewGroup parent) { View v = convertView; ViewHolder holder; /* convertView may be a recycled view but we must recreate it * if it does not correspond to a media view. */ boolean b_createView = true; if (v != null) { holder = (ViewHolder) v.getTag(); if (holder.viewType == VIEW_MEDIA) b_createView = false; } if (b_createView) { LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = inflater.inflate(R.layout.audio_browser_item, parent, false); holder = new ViewHolder(); holder.layout = v.findViewById(R.id.layout_item); holder.title = (TextView) v.findViewById(R.id.title); Util.setAlignModeByPref(mAlignMode, holder.title); holder.cover = (ImageView) v.findViewById(R.id.cover); holder.subtitle = (TextView) v.findViewById(R.id.subtitle); holder.footer = v.findViewById(R.id.footer); holder.more = (ImageView) v.findViewById(R.id.item_more); holder.viewType = VIEW_MEDIA; v.setTag(holder); } else holder = (ViewHolder) v.getTag(); ListItem item = getItem(position); holder.title.setText(item.mTitle); RelativeLayout.LayoutParams paramsCover; if (mItemType == ITEM_WITH_COVER) { Media media = mItems.get(position).mMediaList.get(0); Bitmap cover = AudioUtil.getCover(v.getContext(), media, 64); if (cover == null) cover = BitmapCache.GetFromResource(v, R.drawable.icon); holder.cover.setImageBitmap(cover); int size = (int) mContext.getResources().getDimension(R.dimen.audio_browser_item_size); paramsCover = new RelativeLayout.LayoutParams(size, size); } else paramsCover = new RelativeLayout.LayoutParams(0, RelativeLayout.LayoutParams.WRAP_CONTENT); holder.cover.setLayoutParams(paramsCover); holder.subtitle.setVisibility(item.mSubTitle == null ? TextView.GONE : TextView.VISIBLE); holder.subtitle.setText(item.mSubTitle); // Remove the footer if the item is just above a separator. holder.footer.setVisibility(isMediaItemAboveASeparator(position) ? View.GONE : View.VISIBLE); final int pos = position; holder.more.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { if (mContextPopupMenuListener != null) mContextPopupMenuListener.onPopupMenu(v, pos); } }); return v; }
@Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub ViewHolder holder = null; if (convertView == null) { convertView = LayoutInflater.from(c).inflate(R.layout.item_layout_gallery, null); holder = new ViewHolder(); holder.firstTitle = (TextView) convertView.findViewById(R.id.first_title); holder.secondTitle = (TextView) convertView.findViewById(R.id.second_title); holder.content = (TextView) convertView.findViewById(R.id.content); holder.score = (TextView) convertView.findViewById(R.id.score); holder.image = (ImageView) convertView.findViewById(R.id.image); holder.definition = (ImageView) convertView.findViewById(R.id.definition); holder.layout = (LinearLayout) convertView.findViewById(R.id.bottom_frame); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.firstTitle.setVisibility(View.GONE); holder.layout.setVisibility(View.GONE); holder.definition.setVisibility(View.GONE); holder.image.setImageResource(data[position]); convertView.setPadding( UtilTools.getStandardValue(c, 15), UtilTools.getStandardValue(c, 10), UtilTools.getStandardValue(c, 15), UtilTools.getStandardValue(c, 10)); convertView.setLayoutParams(layoutParam); return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder = null; if (convertView == null) { holder = new ViewHolder(); int w = parent.getWidth() - parent.getPaddingLeft() - parent.getPaddingRight(); int h = parent.getHeight(); RelativeLayout itemlayout = (RelativeLayout) mInflater.inflate(R.layout.item_weather_weekly, parent, false); LayoutParams params = new LayoutParams(w / 5, LayoutParams.MATCH_PARENT); itemlayout.setLayoutParams(params); int wt = itemlayout.getMeasuredWidth(); holder.layout = (RelativeLayout) itemlayout.findViewById(R.id.week_item_rl); holder.textWeek = (TextView) itemlayout.findViewById(R.id.week_item_week); holder.textDate = (TextView) itemlayout.findViewById(R.id.week_item_date); holder.textNongli = (TextView) itemlayout.findViewById(R.id.week_item_nongli); holder.imgWeather = (ImageView) itemlayout.findViewById(R.id.weather_icon); holder.textTemperature = (TextView) itemlayout.findViewById(R.id.week_item_temperature); holder.textWeather = (TextView) itemlayout.findViewById(R.id.week_item_weather); convertView = itemlayout; convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } if (position < info.size()) { WeatherInfo weatherInfo = info.get(position); if (position == 0) holder.textWeek.setText(mContext.getString(R.string.today)); else holder.textWeek.setText( String.format(mContext.getString(R.string.week), weatherInfo.getWeek())); holder.textDate.setText(weatherInfo.getDate()); holder.textNongli.setText(weatherInfo.getNongli()); holder.textTemperature.setText( String.format(mContext.getString(R.string.temperature), weatherInfo.getTemperatureLow()) + "/" + String.format( mContext.getString(R.string.temperature), weatherInfo.getTemperatureHight())); // holder.textWeather.setText(w.weather); int length = weatherInfo.getWeather().length(); if (length > 15 && length <= 18) { holder.textWeather.setTextSize(12); } else if (length > 18 && length <= 21) { holder.textWeather.setTextSize(11); } else if (length > 21) { holder.textWeather.setTextSize(9); } holder.textWeather.setText(weatherInfo.getWeather()); holder.imgWeather.setImageDrawable( mContext.getResources().getDrawable(getDrawableID(weatherInfo.getWeatherID()))); } return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { View view = null; if (convertView == null) { LayoutInflater inflator = context.getLayoutInflater(); view = inflator.inflate(R.layout.rowbuttonlayout, null); final ViewHolder viewHolder = new ViewHolder(); viewHolder.text = (TextView) view.findViewById(R.id.label); viewHolder.checkbox = (CheckBox) view.findViewById(R.id.check); viewHolder.layout = (ViewGroup) view.findViewById(R.id.mylayout); viewHolder.checkbox.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { Model element = (Model) viewHolder.checkbox.getTag(); element.setSelected(buttonView.isChecked()); notifyDataSetChanged(); } }); view.setTag(viewHolder); viewHolder.checkbox.setTag(list.get(position)); } else { view = convertView; ((ViewHolder) view.getTag()).checkbox.setTag(list.get(position)); } ViewHolder holder = (ViewHolder) view.getTag(); holder.text.setText(list.get(position).getName()); boolean selected = list.get(position).isSelected(); holder.checkbox.setChecked(selected); if (selected) { holder.layout.setBackgroundResource(R.drawable.is_selector_focused); } else { holder.layout.setBackground(null); } return view; }
@Override public View getView(int position, View convertView, ViewGroup parent) { int[] aResId = {R.drawable.grey, R.drawable.red}; int START_ID; final int index = position; START_ID = LIUCB_START_ID + position * 3; String team1 = (String) mList.get(position).get("TEAM1"); String team2 = (String) mList.get(position).get("TEAM2"); String scores1 = (String) mList.get(position).get("SCORES1"); String scores2 = (String) mList.get(position).get("SCORES2"); ViewHolder holder = null; convertView = mInflater.inflate(R.layout.buy_football_sixhalf_listitem, null); holder = new ViewHolder(); holder.lie = ((TextView) convertView.findViewById(R.id.liuchangban_lienum)); holder.teamnamerank1 = (TextView) convertView.findViewById(R.id.liuchangban_teamrank1); holder.teamnamerank2 = (TextView) convertView.findViewById(R.id.liuchangban_teamrank2); holder.layout = (LinearLayout) convertView.findViewById(R.id.liuchangban_ball_layout); holder.info = (ImageView) convertView.findViewById(R.id.liuchangban_fenxi); convertView.setTag(holder); LinearLayout itemmainlinear = (LinearLayout) convertView.findViewById(R.id.sixhalforgoalsitem); setFootballListItemBackground(itemmainlinear, position); int liuCBBallFieldWidth = iScreenWidth * 2 / 5; BallTable liucbRow1 = makeBallTable( (LinearLayout) convertView, R.id.liuchangban_ball_1, liuCBBallFieldWidth, aResId, START_ID); ballTables.add(liucbRow1); Vector<OneBallView> BallViews1 = liucbRow1.getBallViews(); for (int i = 0; i < BallViews1.size(); i++) { final OneBallView ball = BallViews1.get(i); ball.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // ball.startAnim(); ball.changeBallColor(); changeTextSumMoney(getZhuShu()); } }); } BallTable liucbRow2 = makeBallTable( (LinearLayout) convertView, R.id.liuchangban_ball_2, liuCBBallFieldWidth, aResId, START_ID); ballTables.add(liucbRow2); Vector<OneBallView> BallViews2 = liucbRow2.getBallViews(); for (int i = 0; i < BallViews2.size(); i++) { final OneBallView ball2 = BallViews2.get(i); ball2.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { ball2.startAnim(); ball2.changeBallColor(); changeTextSumMoney(getZhuShu()); } }); } holder.lie.setText((String.valueOf(position + 1))); if (scores1 == null || scores2.equals(null)) { holder.teamnamerank1.setText(team1); holder.teamnamerank2.setText(team2); } else { holder.teamnamerank1.setText(team1 + "[" + scores1 + "]"); holder.teamnamerank2.setText(team2 + "[" + scores2 + "]"); } holder.info.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { getInfo(index); } }); return convertView; }
@Override public View getView(final int position, View convertView, ViewGroup parent) { int[] aResId = {R.drawable.grey, R.drawable.red}; int START_ID; final int index = position; START_ID = SHENGFC_START_ID + position * 3; String team1 = (String) mList.get(position).get("TEAM1"); String team2 = (String) mList.get(position).get("TEAM2"); String scores1 = (String) mList.get(position).get("SCORES1"); String scores2 = (String) mList.get(position).get("SCORES2"); ViewHolder holder = null; holder = new ViewHolder(); convertView = mInflater.inflate(R.layout.buy_football_sforchosenine_listitem, parent, false); holder.lie = ((TextView) convertView.findViewById(R.id.lienum)); holder.teamname = (TextView) convertView.findViewById(R.id.teamname); holder.teamrank = (TextView) convertView.findViewById(R.id.teamrank); holder.layout = (LinearLayout) convertView.findViewById(R.id.shengfucai_layout); holder.info = (ImageView) convertView.findViewById(R.id.fenxi); LinearLayout linearSF = (LinearLayout) convertView.findViewById(R.id.sforchoosenine_item); setFootballListItemBackground(linearSF, position); int aFieldWidth = iScreenWidth / 3; BallTable shengfcRow = null; shengfcRow = makeBallTable(holder.layout, R.id.shengfucai_ball, aResId, START_ID); if (ballTables.size() < mList.size()) { ballTables.add(shengfcRow); } Vector<OneBallView> BallViews = shengfcRow.getBallViews(); for (int i = 0; i < BallViews.size(); i++) { final OneBallView ball = BallViews.get(i); ball.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // ball.startAnim(); ball.changeBallColor(); changeTextSumMoney(getZhuShu()); } }); } if (position < 9) { holder.lie.setText((String.valueOf(position + 1)) + " "); } else { holder.lie.setText((String.valueOf(position + 1))); } if (team1.length() == 2) { team1 = " " + team1; } if (team2.length() == 2) { team2 += " "; } holder.teamname.setText(team1 + "VS" + team2); try { if (scores1 != null) { holder.teamrank.setText(" " + scores1 + " " + scores2); } } catch (Exception e) { } holder.info.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { getInfo(index); } }); return convertView; }