@Override public void onQueryTabsComplete(List<TabsAccessor.RemoteTab> tabsList) { ArrayList<TabsAccessor.RemoteTab> tabs = new ArrayList<TabsAccessor.RemoteTab>(tabsList); if (tabs == null || tabs.size() == 0) { mRemoteTabs.hide(); return; } mRemoteTabs.clear(); String client = null; for (TabsAccessor.RemoteTab tab : tabs) { if (client == null) client = tab.name; else if (!TextUtils.equals(client, tab.name)) break; final RelativeLayout row = (RelativeLayout) mInflater.inflate( R.layout.abouthome_remote_tab_row, mRemoteTabs.getItemsContainer(), false); ((TextView) row.findViewById(R.id.remote_tab_title)) .setText(TextUtils.isEmpty(tab.title) ? tab.url : tab.title); row.setTag(tab.url); mRemoteTabs.addItem(row); row.setOnClickListener(mRemoteTabClickListener); } mRemoteTabs.setSubtitle(client); mRemoteTabs.show(); }
@Override public View getView(int i, View view, ViewGroup viewGroup) { ViewHolder viewHolder = null; RelativeLayout row = null; if (view == null) { LayoutInflater inflater = mActivity.getLayoutInflater(); row = (RelativeLayout) inflater.inflate(LAYOUT_ID, null); viewHolder = new ViewHolder(); viewHolder.mImageViewProfilePicture = (ImageView) row.findViewById(R.id.adapter_profile_picture); viewHolder.mRatingBar = (RatingBar) row.findViewById(R.id.adapter_rating); viewHolder.mTextViewChannelName = (TextView) row.findViewById(R.id.adapter_channel_name); viewHolder.mTextViewFollower = (TextView) row.findViewById(R.id.adapter_followers); viewHolder.mTextViewUserName = (TextView) row.findViewById(R.id.adapter_user_name); viewHolder.mImageViewCover = (ImageView) row.findViewById(R.id.adapter_live_cover_image); FontsUtil.setViewGroupTypeface((ViewGroup) row, mActivity); row.setTag(viewHolder); } else { row = (RelativeLayout) view; viewHolder = (ViewHolder) row.getTag(); } ChannelPOJO channelPOJO = (ChannelPOJO) getItem(i); viewHolder.mTextViewChannelName.setText(channelPOJO.getName()); viewHolder.mTextViewFollower.setText( String.valueOf(channelPOJO.getFollowersCount()) .concat(" ") .concat(mActivity.getString(R.string.followers))); viewHolder.mTextViewUserName.setText(channelPOJO.getUserPOJO().getUserName()); if (!TextUtils.isEmpty(channelPOJO.getUserPOJO().getProfilePicture())) { Picasso.with(mActivity) .load(channelPOJO.getUserPOJO().getProfilePicture()) .transform(new PicassoCircleTransformation()) .into(viewHolder.mImageViewProfilePicture); } else { Picasso.with(mActivity) .load(R.drawable.default_avatar) .transform(new PicassoCircleTransformation()) .into(viewHolder.mImageViewProfilePicture); } if (!TextUtils.isEmpty(channelPOJO.getCoverImage())) { Picasso.with(mActivity).load(channelPOJO.getCoverImage()).into(viewHolder.mImageViewCover); } Log.d("CuongCuongCuong", "channelPOJO.getRating " + channelPOJO.getRating()); viewHolder.mRatingBar.setRating((float) channelPOJO.getRating()); return row; }
private void InitaializeData() { BaseActivity.imageLoader.displayImage(CurrentUser.getProfileImage(), myAvatorImageView, o); DBManager dbManager = new DBManager(this); List<Building> localBuildings = dbManager.GetLocalBuildings(CurrentUser.getId()); if (localBuildings != null) { for (Building building : localBuildings) { if (building.getHome() == 1) { myHome.setTag(building); myHomeImageView.setVisibility(View.VISIBLE); BaseActivity.imageLoader.displayImage(building.getFaceUrl(), myHomeImageView); } else if (building.getWork() == 1) { myWork.setTag(building); myWorkImageView.setVisibility(View.VISIBLE); BaseActivity.imageLoader.displayImage(building.getFaceUrl(), myWorkImageView); } } } dbManager.closeDB(); nickNameView.setText(CurrentUser.getName() != null ? CurrentUser.getName() : "还没有昵称"); accountNameView.setText(CurrentUser.getEmail()); }
@Override public View getView(int position, View convertView, ViewGroup parent) { try { if (convertView == null) { convertView = inflater.inflate(R.layout.item_inland_airlineticket_passenger_list, null); } View divid_line = convertView.findViewById(R.id.divid_line); TextView passengerName_tv = (TextView) convertView.findViewById(R.id.passengerName_tv); TextView identificationType_tv = (TextView) convertView.findViewById(R.id.identificationType_tv); TextView identificationNum_tv = (TextView) convertView.findViewById(R.id.identificationNum_tv); TextView passengerType_tv = (TextView) convertView.findViewById(R.id.passengerType_tv); passengerName_tv.setText(str.get(position).getPassengerName()); identificationType_tv.setText(str.get(position).getIdentificationType()); identificationNum_tv.setText(str.get(position).getIdentificationNum()); passengerType_tv.setText("(" + str.get(position).getPassengerType() + ")"); RelativeLayout passenger_rl = (RelativeLayout) convertView.findViewById(R.id.passenger_rl); passenger_rl.setTag(position + ""); if (position == passengerList.size() - 1) { divid_line.setVisibility(View.GONE); } ImageButton delete_imgbtn = (ImageButton) convertView.findViewById(R.id.delete_imgbtn); delete_imgbtn.setTag(position + ""); // 给Item中的button设置tag,根据tag判断用户点击了第几行 delete_imgbtn.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { try { int index = Integer.parseInt(v.getTag().toString()); passengerList.remove(index); notifyDataSetChanged(); ActivityInlandAirlineticketBooking.setListViewHeightBasedOnChildren( passenger_listview); if (passengerList.size() == 0) { add_passager_tv.setText(getResources().getString(R.string.add_passenger)); passenger_head_divid_line.setVisibility(View.GONE); } caculateMoney(); } catch (Exception e) { e.printStackTrace(); } } }); } catch (Exception e) { e.printStackTrace(); } return convertView; }
@Override public void bindView(View view, Context context, Cursor cursor) { // Get the decoration for the current row Decoration decoration = mDecorationCursor.getDecoration(); RelativeLayout itemLayout = (RelativeLayout) view.findViewById(R.id.listitem); // Set up the text view ImageView itemImageView = (ImageView) view.findViewById(R.id.item_image); TextView decorationNameTextView = (TextView) view.findViewById(R.id.item); TextView skill1TextView = (TextView) view.findViewById(R.id.skill1); TextView skill1amtTextView = (TextView) view.findViewById(R.id.skill1_amt); TextView skill2TextView = (TextView) view.findViewById(R.id.skill2); TextView skill2amtTextView = (TextView) view.findViewById(R.id.skill2_amt); String decorationNameText = decoration.getName(); String skill1Text = decoration.getSkill1Name(); String skill1amtText = "" + decoration.getSkill1Point(); String skill2Text = decoration.getSkill2Name(); String skill2amtText = ""; if (decoration.getSkill2Point() != 0) { skill2amtText = skill2amtText + decoration.getSkill2Point(); } Drawable i = null; String cellImage = "icons_items/" + decoration.getFileLocation(); try { i = Drawable.createFromStream(context.getAssets().open(cellImage), null); } catch (IOException e) { e.printStackTrace(); } itemImageView.setImageDrawable(i); decorationNameTextView.setText(decorationNameText); skill1TextView.setText(skill1Text); skill1amtTextView.setText(skill1amtText); skill2TextView.setVisibility(View.GONE); skill2amtTextView.setVisibility(View.GONE); if (!skill2amtText.equals("")) { skill2TextView.setText(skill2Text); skill2amtTextView.setText(skill2amtText); skill2TextView.setVisibility(View.VISIBLE); skill2amtTextView.setVisibility(View.VISIBLE); } itemLayout.setTag(decoration.getId()); itemLayout.setOnClickListener(new DecorationClickListener(context, decoration.getId())); }
@Override public View getViewForListElement(LayoutInflater layoutInflater, Context context, View view) { // TODO Auto-generated method stub layout = (RelativeLayout) layoutInflater.inflate(getLayoutId(), null); layout.setTag(tag); textView = (TextView) layout.findViewById(R.id.health_plus_personal_info_edit_text_item_name_tv); valueView = (TextView) layout.findViewById(R.id.health_plus_personal_info_edit_text_item_value_tv); valueView.setText(value); textView.setText(name); return layout; }
@Override public View getView(int position, View convertView, ViewGroup parent) { RelativeLayout songLay = (RelativeLayout) songInf.inflate(R.layout.albumpressedelement, parent, false); // get title and artist views TextView songsView = (TextView) songLay.findViewById(R.id.trackname); TextView artistsView = (TextView) songLay.findViewById(R.id.albartisname); // get song using position Song currSong = songs.get(position); // get title and artist strings songsView.setText(currSong.getTitle()); artistsView.setText(currSong.getArtist()); // set position as tag songLay.setTag(position); return songLay; }
private void showInfoView(MyPoiInfo info) { rl_info.setVisibility(View.VISIBLE); tv_name.setText(info.name); tv_addr.setText(info.address); double distance = DistanceUtil.getDistance( new LatLng(cLoc.getLatitude(), cLoc.getLongitude()), new LatLng(info.lat, info.lng)); if (distance > 1000) { tv_distance.setText(String.format("%.2f千米", distance / 100.0)); } else { tv_distance.setText(String.format("%d米", (int) distance)); } btn_do.setText(type == 1 ? "前往" : "详情"); rl_info.setTag(type == 1 ? info : null); }
private void initViews(Context context) { mRootView = (LinearLayout) (LayoutInflater.from(context).inflate(R.layout.view_navigation_bar, this)) .findViewById(R.id.llyt_root); mTabs = new ArrayList<>(); int tabIndex = 0; for (int i = 0, size = mRootView.getChildCount(); i < size; i++) { if (mRootView.getChildAt(i) instanceof RelativeLayout) { RelativeLayout tab = (RelativeLayout) mRootView.getChildAt(i); mTabs.add(tab); TextView tv = getTextViewFromTab(tab); if (tv != null) { tv.setText(mTabTitles[tabIndex]); tv.setTextColor(mColorNormal); } tab.setTag(tabIndex); tab.setOnClickListener(this); tabIndex++; } } }
@Override public View getView(int position, View convertView, ViewGroup parent) { RelativeLayout todoView = null; final VideoModel video = getItem(position); ViewHolder holder = new ViewHolder(); String tag = "" + position + ""; for (int x = 0; x < views.size(); x++) { todoView = (RelativeLayout) views.get(x); if (todoView.getTag().equals(tag)) { return todoView; } } /* * if (convertView == null) { todoView = new * RelativeLayout(getContext()); String inflater = * Context.LAYOUT_INFLATER_SERVICE; LayoutInflater li = * (LayoutInflater) getContext().getSystemService( inflater); * li.inflate(resource, todoView, true); } else { todoView = * (RelativeLayout) convertView; } */ todoView = new RelativeLayout(getContext()); String inflater = Context.LAYOUT_INFLATER_SERVICE; LayoutInflater li = (LayoutInflater) getContext().getSystemService(inflater); li.inflate(resource, todoView, true); // holder.btn = (Button) todoView.findViewById(R.id.video_item_btn); holder.title = (TextView) todoView.findViewById(R.id.video_item_title); holder.tv_duration = (TextView) todoView.findViewById(R.id.tv_duration); String duration = ""; try { final NumberFormat formatter = NumberFormat.getNumberInstance(Locale.getDefault()); formatter.setMaximumFractionDigits(2); int durationInt = Integer.parseInt(video.getDuration()); Double minutes = Math.floor(durationInt / 60.0); Double seconds = Math.floor((durationInt) - (minutes * 60)); String str_min = formatter.format(minutes); if (minutes <= 9) { str_min = "0" + formatter.format(minutes); } String str_sec = formatter.format(seconds); if (seconds <= 9) { str_sec = "0" + formatter.format(seconds); } duration = str_min + " : " + str_sec; } catch (Exception e) { duration = c.getResources().getString(R.string.not_set); } holder.tv_duration.setText(duration); /* * holder.btn.setOnClickListener(new OnClickListener() { * * @Override public void onClick(View v) { Intent n = new Intent(c, * Ac_Video.class); n.putExtra("video_id", video.getID()); * c.startActivity(n); * * } }) ; */ holder.img_favorited = (ImageView) todoView.findViewById(R.id.img_favorited); if (dba.checkFavoStatus(video)) { holder.img_favorited.setImageResource(R.drawable.btn_favhover); } else { holder.img_favorited.setImageResource(R.drawable.btn_fav); } holder.img = (UIImage) todoView.findViewById(R.id.video_item_image); // default.jpg height:90,width:120 // mqdefault.jpg,height:180,width:320 // hqdefault.jpg,height:360,width:480 String imageUrl = "http://i.ytimg.com/vi/" + video.getID() + "/mqdefault.jpg"; if (UIPlayList.isTablet(c)) { imageUrl = "http://i.ytimg.com/vi/" + video.getID() + "/hqdefault.jpg"; } holder.img.onAttacheActoin = false; holder.img.setImage(new ImageFileModel(imageUrl, null, null), 0, 0); holder.title.setText(video.getTitle()); todoView.setTag(tag); views.add(todoView); return todoView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { RelativeLayout v; View child; // Log.d("mobeta", // "getView: position="+position+" convertView="+convertView); if (convertView != null) { v = (RelativeLayout) convertView; View oldChild = v.getChildAt(0); // child = super.getView(position, oldChild, v); child = mAdapter.getView(position, oldChild, v); if (child != oldChild) { // shouldn't get here if user is reusing convertViews // properly v.removeViewAt(0); v.addView(child); // check that tags are equal too? v.setTag(child.findViewById(R.id.drag)); } } else { AbsListView.LayoutParams params = new AbsListView.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); v = new RelativeLayout(getContext()); v.setLayoutParams(params); child = mAdapter.getView(position, null, v); v.addView(child); v.setTag(child.findViewById(R.id.drag)); } ViewGroup.LayoutParams lp = v.getLayoutParams(); final int numHeaders = getHeaderViewsCount(); final int srcAdapter = mSrcDragPos - numHeaders; final int expAdapter = mExpDragPos - numHeaders; boolean itemIsNormal = position != srcAdapter && position != expAdapter; boolean listHasExpPos = mDragState == SRC_ABOVE || mDragState == SRC_BELOW; boolean itemNeedsWC = itemIsNormal || !listHasExpPos; int oldHeight = lp.height; if (itemNeedsWC && lp.height != ViewGroup.LayoutParams.WRAP_CONTENT) { // items that have a user-provided height lp.height = ViewGroup.LayoutParams.WRAP_CONTENT; } else if (listHasExpPos) { if (position == srcAdapter && lp.height != mItemHeightCollapsed) { // collapsed items lp.height = mItemHeightCollapsed; } else if (position == expAdapter) { // what if a previously-expanded wrapper view is used // as a convertView for a different expanded item? // Always measure child int spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); child.measure(spec, spec); mExpandedChildHeight = child.getMeasuredHeight(); // Log.d("mobeta", // "childh="+mExpandedChildHeight+" pos="+position); int height = mExpandedChildHeight + mFloatViewHeight; if (lp.height != height) { lp.height = height; } // set gravity if (mDragState == SRC_ABOVE) { v.setGravity(Gravity.TOP); } else { v.setGravity(Gravity.BOTTOM); } } } if (lp.height != oldHeight) { v.setLayoutParams(lp); } int oldVis = v.getVisibility(); int vis = oldVis; if (position == srcAdapter && mDragState != NO_DRAG) { if (vis == View.VISIBLE) { vis = View.INVISIBLE; } } else if (vis == View.INVISIBLE) { vis = View.VISIBLE; } if (vis != oldVis) { v.setVisibility(vis); } return v; }
@Override public View getView(int position, View convertView, ViewGroup parent) { final ViewHolder holder; if (convertView == null) { convertView = inflater.inflate(R.layout.item_zhuoinfo_list, null); holder = initHolder(convertView); convertView.setTag(R.id.tag_view_holder, holder); } else { holder = (ViewHolder) convertView.getTag(R.id.tag_view_holder); } ZhuoInfoVO zhuoinfo = mList.get(position); String id = zhuoinfo.getMsgid(); UserVO user = zhuoinfo.getUser(); String uid = user.getUserid(); String company = user.getCompany(); String authorName = user.getUsername(); String headUrl = user.getUheader(); String work = user.getPost(); String type = zhuoinfo.getType(); String category = zhuoinfo.getCategory(); String title = zhuoinfo.getTitle(); String detail = zhuoinfo.getText(); convertView.setTag(R.id.tag_id, id); convertView.setTag(R.id.tag_string, type); holder.nameTV.setText(authorName); String woco = ZhuoCommHelper.concatStringWithTag(work, company, "|"); if (woco.length() > 1) { holder.workTV.setText(woco); holder.workTV.setVisibility(View.VISIBLE); } else { holder.workTV.setText(""); holder.workTV.setVisibility(View.GONE); } if (type != null && !type.equals("")) { Map<String, Object> resinfo = ZhuoCommHelper.gentResInfo(type, category, title, detail, mContext); holder.resIV.setImageResource((Integer) resinfo.get("ico")); String text = (String) resinfo.get("category") + (String) resinfo.get("title") + (String) resinfo.get("content"); holder.resTV.setText(text); Rect bounds = new Rect(); TextPaint paint = holder.resTV.getPaint(); paint.getTextBounds(text, 0, text.length(), bounds); int width = bounds.width(); if (width / (this.width - 81 * times) > 4) { holder.moreTV.setVisibility(View.VISIBLE); } else { holder.moreTV.setVisibility(View.GONE); } } else { holder.resIV.setImageResource(0); holder.resTV.setText(""); } holder.resTV.setMaxLines(4); holder.moreTV.setText(R.string.info1); holder.tl.removeAllViews(); holder.headIV.setImageResource(R.drawable.default_userhead); holder.headIV.setTag(headUrl); mLoadImage.addTask(headUrl, holder.headIV); final List<PicVO> pics = zhuoinfo.getPic(); RelativeLayout.LayoutParams layoutParams = holder.rlp; if (pics != null && pics.size() == 1) { layoutParams = holder.rlp2; } if (pics != null && pics.size() > 0) { TableRow tr = null; for (int i = 0; i < pics.size(); i++) { if (i % 3 == 0) { tr = new TableRow(mContext); holder.tl.addView(tr); } tr.setLayoutParams(holder.tllp); RelativeLayout rl = new RelativeLayout(mContext); rl.setLayoutParams(holder.trlp); ImageView iv = new ImageView(mContext); iv.setLayoutParams(layoutParams); rl.addView(iv); rl.setTag(pics.get(i).getOrgurl()); iv.setTag(pics.get(i).getUrl()); iv.setImageResource(R.drawable.default_image); mLoadImage.addTask(pics.get(i).getUrl(), iv); rl.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(mContext, PhotoViewMultiActivity.class); ArrayList<String> orgs = new ArrayList<String>(); for (int j = 0; j < pics.size(); j++) { orgs.add(pics.get(j).getOrgurl()); } intent.putStringArrayListExtra("pics", orgs); intent.putExtra("pic", (String) v.getTag()); mContext.startActivity(intent); } }); tr.addView(rl); } } String place = zhuoinfo.getPosition(); if (null == place) { place = ""; } String time = zhuoinfo.getAddtime(); time = CommonUtil.calcTime(time); holder.timeTV.setText(time + " " + place); if (myid.equals(uid)) { holder.delTV.setVisibility(View.VISIBLE); } else { holder.delTV.setVisibility(View.GONE); } List<String> tags = zhuoinfo.getTags(); if (tags != null && tags.size() > 0) { String tagStr = " "; for (String tag : tags) { tagStr += tag + " "; } holder.tagTV.setText(tagStr); holder.relativeLayoutTag.setVisibility(View.VISIBLE); } else { holder.relativeLayoutTag.setVisibility(View.GONE); } String cmtNum = zhuoinfo.getCmtnum(); String goodNum = zhuoinfo.getGoodnum(); String collectNum = zhuoinfo.getCollectnum(); String zfNum = zhuoinfo.getForwardnum(); if (null == cmtNum || cmtNum.equals("")) { cmtNum = "0"; } if (null == goodNum || goodNum.equals("")) { goodNum = "0"; } if (null == collectNum || collectNum.equals("")) { collectNum = "0"; } if (null == zfNum || zfNum.equals("")) { zfNum = "0"; } holder.goodNumTV.setText(goodNum); holder.cmtNumTV.setText(cmtNum); holder.zfNumTV.setText(zfNum); holder.collectNumTV.setText(collectNum); List<CmtVO> cmts = zhuoinfo.getCmt(); if (cmts != null && cmts.size() > 0) { holder.layoutGongXuCmt.setBackgroundResource(R.drawable.shape_gray_corners); for (CmtVO msg : cmts) { LinearLayout layoutCmtOne = new LinearLayout(mContext); layoutCmtOne.setLayoutParams(holder.layoutParams); layoutCmtOne.setOrientation(LinearLayout.HORIZONTAL); TextView userTv = new TextView(mContext); userTv.setLayoutParams(holder.layoutParams); userTv.setTextColor(0xff41546d); TextView contentTV = new TextView(mContext); contentTV.setLayoutParams(holder.layoutParams); UserVO cmtUser = msg.getUser(); String uname = cmtUser.getUsername(); String userid = cmtUser.getUserid(); String msgContent = msg.getContent(); userTv.setText(uname + ":"); contentTV.setText(msgContent); layoutCmtOne.addView(userTv); layoutCmtOne.addView(contentTV); layoutCmtOne.setTag(userid); holder.layoutGongXuCmt.addView(layoutCmtOne); } } initEvent(holder, convertView, id, uid); mLoadImage.doTask(); return convertView; }