Java Code Examples for android.view.View.setTag()

The following are Jave code examples for showing how to use setTag() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: GitHub   File: ChannelAdapter.java   Source Code and License Vote up 8 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holer;
    if (convertView == null) {
        convertView = View.inflate(mContext, R.layout.item_channel, null);
        holer = new ViewHolder(convertView);
        convertView.setTag(holer);
    } else {
        holer = (ViewHolder) convertView.getTag();
    }

    ResultBean.ChannelInfoBean channelInfoBean = channel_info.get(position);
    holer.tvChannel.setText(channelInfoBean.getChannel_name());
    Glide.with(mContext)
            .load(Constants.BASE_URl_IMAGE +channelInfoBean.getImage())
            .into(holer.ivChannel);
    return convertView;
}
 
Example 2
Project: RNLearn_Project1   File: RedBoxDialog.java   Source Code and License Vote up 7 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {
  if (position == 0) {
    TextView title = convertView != null
        ? (TextView) convertView
        : (TextView) LayoutInflater.from(parent.getContext())
            .inflate(R.layout.redbox_item_title, parent, false);
    title.setText(mTitle);
    return title;
  } else {
    if (convertView == null) {
      convertView = LayoutInflater.from(parent.getContext())
          .inflate(R.layout.redbox_item_frame, parent, false);
      convertView.setTag(new FrameViewHolder(convertView));
    }
    StackFrame frame = mStack[position - 1];
    FrameViewHolder holder = (FrameViewHolder) convertView.getTag();
    holder.mMethodView.setText(frame.getMethod());
    holder.mFileView.setText(StackTraceHelper.formatFrameSource(frame));
    return convertView;
  }
}
 
Example 3
Project: buildAPKsApps   File: FactAdapter.java   Source Code and License Vote up 7 votes
public View getView(int position, View convertView, ViewGroup parent) {
	View view = convertView;
	ViewHolder holder;
	if (convertView == null) {
		view = inflater.inflate(R.layout.item_fact, null);
		holder = new ViewHolder();
		holder.tv_id = (TextView) view.findViewById(R.id.textView_item_id);
		;
		holder.tv_fact = (TextView) view
				.findViewById(R.id.textView_item_fact);
		view.setTag(holder);
	} else
		holder = (ViewHolder) view.getTag();

	String str_id = mSubData.get(position).getId() + "";
	if (mSubData.get(position).getId() == -1)
		str_id = "Unknown Id";
	holder.tv_id.setText(str_id);
	holder.tv_fact.setText(mSubData.get(position).getFact());

	return view;
}
 
Example 4
Project: pius1   File: MainActivity.java   Source Code and License Vote up 7 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    ViewHolder holder = null;
    if (convertView == null) {
        holder = new ViewHolder();
        convertView = LayoutInflater.from(MainActivity.this).inflate(R.layout.item_search_history_word, null);
        holder.tv_word = (TextView) convertView.findViewById(R.id.tv_search_record);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }

    holder.tv_word.setText(historywordsList.get(position).toString());

    return convertView;
}
 
Example 5
Project: AndroidNetwork   File: CinemaAdapter.java   Source Code and License Vote up 7 votes
public View getView(final int position, View convertView,
		final ViewGroup parent) {
	final Holder holder;
	if (convertView == null) {
		holder = new Holder();
		convertView = context.getLayoutInflater().inflate(
				R.layout.item_cinemalist, null);
		holder.tvCinemaName = (TextView) convertView
				.findViewById(R.id.tvCinemaName);
		holder.tvCinemaId = (TextView) convertView
				.findViewById(R.id.tvCinemaId);
		convertView.setTag(holder);
	} else {
		holder = (Holder) convertView.getTag();
	}

	CinemaBean cinema = cinemaList.get(position);
	holder.tvCinemaName.setText(cinema.getCinemaName());
	holder.tvCinemaId.setText(cinema.getCinemaId());
	return convertView;
}
 
Example 6
Project: AndroidNetwork   File: CinemaAdapter.java   Source Code and License Vote up 7 votes
public View getView(final int position, View convertView,
		final ViewGroup parent) {
	final Holder holder;
	if (convertView == null) {
		holder = new Holder();
		convertView = context.getLayoutInflater().inflate(
				R.layout.item_cinemalist, null);
		holder.tvCinemaName = (TextView) convertView
				.findViewById(R.id.tvCinemaName);
		holder.tvCinemaId = (TextView) convertView
				.findViewById(R.id.tvCinemaId);
		convertView.setTag(holder);
	} else {
		holder = (Holder) convertView.getTag();
	}

	CinemaBean cinema = cinemaList.get(position);
	holder.tvCinemaName.setText(cinema.getCinemaName());
	holder.tvCinemaId.setText(cinema.getCinemaId());
	return convertView;
}
 
Example 7
Project: eBread   File: SettingListAdapter.java   Source Code and License Vote up 7 votes
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
    ViewHolder viewHolder;
    if(convertView == null){
        LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.setting_list_row, null);
        viewHolder = new ViewHolder();
        viewHolder.title = (TextView) convertView.findViewById(R.id.tvSettingList);
        convertView.setTag(viewHolder);
    }else{
        viewHolder = (ViewHolder) convertView.getTag();
    }
    Setting setting = getItem(position);
    viewHolder.title.setText(setting.getName());
    return convertView;
}
 
Example 8
Project: GitHub   File: BaseItemDraggableAdapter.java   Source Code and License Vote up 7 votes
/**
 * To bind different types of holder and solve different the bind events
 *
 * @param holder
 * @param positions
 * @see #getDefItemViewType(int)
 */
@Override
public void onBindViewHolder(K holder, int positions) {
    super.onBindViewHolder(holder, positions);
    int viewType = holder.getItemViewType();

    if (mItemTouchHelper != null && itemDragEnabled && viewType != LOADING_VIEW && viewType != HEADER_VIEW
            && viewType != EMPTY_VIEW && viewType != FOOTER_VIEW) {
        if (mToggleViewId != NO_TOGGLE_VIEW) {
            View toggleView = ((BaseViewHolder) holder).getView(mToggleViewId);
            if (toggleView != null) {
                toggleView.setTag(R.id.BaseQuickAdapter_viewholder_support, holder);
                if (mDragOnLongPress) {
                    toggleView.setOnLongClickListener(mOnToggleViewLongClickListener);
                } else {
                    toggleView.setOnTouchListener(mOnToggleViewTouchListener);
                }
            }
        } else {
            holder.itemView.setTag(R.id.BaseQuickAdapter_viewholder_support, holder);
            holder.itemView.setOnLongClickListener(mOnToggleViewLongClickListener);
        }
    }
}
 
Example 9
Project: Mybilibili   File: CBPageAdapter.java   Source Code and License Vote up 6 votes
@Override public View getView(final int position, View view, ViewGroup container) {
    if (view == null) {
        holder = (Holder) holderCreator.createHolder();
        view = holder.createView(container.getContext());
        view.setTag(holder);
    } else {
        holder = (Holder<T>) view.getTag();
    }
    if(mDatas!=null&&!mDatas.isEmpty()){
       holder.UpdateUI(container.getContext(), position, mDatas.get(position));
    }

    return view;
}
 
Example 10
Project: SimpleUILauncher   File: Workspace.java   Source Code and License Vote up 6 votes
private void enfoceDragParity(View v, String event, int update, int expectedValue) {
    Object tag = v.getTag(R.id.drag_event_parity);
    int value = tag == null ? 0 : (Integer) tag;
    value += update;
    v.setTag(R.id.drag_event_parity, value);

    if (value != expectedValue) {
        Log.e(TAG, event + ": Drag contract violated: " + value);
    }
}
 
Example 11
Project: FlycoTablayout   File: SegmentTabLayout.java   Source Code and License Vote up 6 votes
/** 更新数据 */
public void notifyDataSetChanged() {
    mTabsContainer.removeAllViews();
    this.mTabCount = mTitles.length;
    View tabView;
    for (int i = 0; i < mTabCount; i++) {
        tabView = View.inflate(mContext, R.layout.layout_tab_segment, null);
        tabView.setTag(i);
        addTab(i, tabView);
    }

    updateTabStyles();
}
 
Example 12
Project: MobileAppForPatient   File: SearchMeterDialog.java   Source Code and License Vote up 6 votes
public View getView(final int position, View convertView, ViewGroup parent) {
 		
 		ViewHolder viewHolder = null;
 		View vi = convertView;
 		if(convertView == null) {
 			vi = inflater.inflate(R.layout.listview_content_search, null);
 			viewHolder = new ViewHolder();
 			viewHolder.tvTitle = (TextView) vi.findViewById(R.id.tv_title);
 			viewHolder.btnDel = (Button) vi.findViewById(R.id.btn_del);
 			vi.setTag(viewHolder);
 		}
 		else {
 			viewHolder = (ViewHolder) convertView.getTag();
 		}
 		
 		viewHolder.tvTitle.setText(mSearchedDevices.get(position).getName().toString());
 		viewHolder.btnDel.setOnClickListener(new View.OnClickListener() {
	
	@Override
	public void onClick(View v) {
		BluetoothDevice searchedDevice = mSearchedDevices.get(position);
		String macAddress = searchedDevice.getAddress();
   		if (!(macAddress.equals("N/A") || TextUtils.isEmpty(macAddress))) {
   			if (mHandler != null) {
   				mHandler.OnSearchBLEClicked(searchedDevice);
   			}
           }
           
           dismiss();
	}
});
 		
 		return vi;
 	}
 
Example 13
Project: duo-navigation-drawer   File: DuoMenuView.java   Source Code and License Vote up 6 votes
/**
 * Handles the footer view.
 */
private void handleFooter() {
    if (mFooterViewId == DEFAULT_LAYOUT_ATTRIBUTE_VALUE || mMenuViewHolder.mMenuFooter == null) {
        return;
    }

    View view = mLayoutInflater.inflate(mFooterViewId, null, false);

    if (view != null) {
        if (mMenuViewHolder.mMenuFooter.getChildCount() > 0) {
            mMenuViewHolder.mMenuFooter.removeAllViews();
        }

        mMenuViewHolder.mMenuFooter.addView(view);
        view.setTag(TAG_FOOTER);
        view.bringToFront();

        if (view instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) view;

            for (int i = 0; i < viewGroup.getChildCount(); i++) {
                if (viewGroup.getChildAt(i) instanceof Button) {
                    viewGroup.getChildAt(i).setOnClickListener(new OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            if (mOnMenuClickListener != null) {
                                mOnMenuClickListener.onFooterClicked();
                            }
                        }
                    });
                    return;
                }
            }
        }
    }
}
 
Example 14
Project: YCCustomText   File: HyperTextEditor.java   Source Code and License Vote up 6 votes
/**
 * 生成图片View
 */
private RelativeLayout createImageLayout() {
    RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.edit_image_view, null);
    layout.setTag(viewTagIndex++);
    View closeView = layout.findViewById(R.id.image_close);
    //closeView.setVisibility(GONE);
    closeView.setTag(layout.getTag());
    closeView.setOnClickListener(btnListener);
    return layout;
}
 
Example 15
Project: Tribe   File: PhotoGridViewAdapter.java   Source Code and License Vote up 6 votes
@Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
    GridViewHolder holder = null;
    if(convertView == null){
        convertView = LayoutInflater.from(mContext).inflate(R.layout.rl_photo_gridview_item,viewGroup,false);
        holder = new GridViewHolder(convertView);
        convertView.setTag(holder);
    }else {
        holder = (GridViewHolder) convertView.getTag();
    }

    OvLoad ovLoad = new OvLoad();
    if(position != 0){
        String path = (String) mData.get(position);
        ovLoad.loadPicture(mActivity,path,holder.mImg);
    }else {
        //位置0 加载本地资源文件
        int itemPath = (int) mData.get(position);
        GlideApp.with(mContext)
                .load(itemPath)
                .transition(new DrawableTransitionOptions().crossFade(200))
                .centerCrop()
                .into(holder.mImg);
    }


    return convertView;
}
 
Example 16
Project: Retrospector-Android   File: ReviewAdapter.java   Source Code and License Vote up 5 votes
public View getView(int position, View convertView, ViewGroup parent) {
        View v = convertView;

        ReviewAdapter.PlanetHolder holder = new ReviewAdapter.PlanetHolder();
        final Review p = planetList.get(position);

        // First let's verify the convertView is not null
        if (convertView == null) {
            // This a new view we inflate the new layout
            LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            final View v2 = inflater.inflate(R.layout.item_review, null);
            v2.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
//                    Toast.makeText(v2.getContext(),"User: "+p.getUser(),Toast.LENGTH_LONG).show();
                    Intent toReviewWeGo = new Intent(v2.getContext(), ReviewActivity.class);
                    toReviewWeGo.putExtra("Media ID",p.getMediaId());
                    toReviewWeGo.putExtra("Review ID",p.getId());
                    v2.getContext().startActivity(toReviewWeGo);
                }
            });
            // Now we can fill the layout with the right values
            TextView user = (TextView) v2.findViewById(R.id.txtvUser);
            TextView date = (TextView) v2.findViewById(R.id.txtvDate);
            TextView rate = (TextView) v2.findViewById(R.id.txtvRating);


            holder.userView = user;
            holder.dateView = date;
            holder.ratingView = rate;

            v2.setTag(holder);
            v = v2;
        }
        else {
            holder = (ReviewAdapter.PlanetHolder) v.getTag();
        }

        holder.userView.setText(p.getUser());
        holder.dateView.setText(dateFormat.format(p.getDate()));
        holder.ratingView.setText(p.getRating()+"");

        if (position%2==0)
            v.setBackgroundColor(Color.LTGRAY);
        else
            v.setBackgroundColor(Color.WHITE);

        return v;
    }
 
Example 17
Project: baselibrary-master   File: ViewHolder.java   Source Code and License Vote up 5 votes
public ViewHolder setTag(int viewId, Object tag) {
    View view = getView(viewId);
    view.setTag(tag);
    return this;
}
 
Example 18
Project: Mobike   File: RouteLineAdapter.java   Source Code and License Vote up 5 votes
@Override
    public View getView(int position, View convertView, ViewGroup parent) {
        NodeViewHolder holder;
        if (convertView == null) {
            convertView = layoutInflater.inflate(R.layout.activity_transit_item, null);
            holder = new NodeViewHolder();
            holder.name = (TextView) convertView.findViewById(R.id.transitName);
            holder.lightNum = (TextView) convertView.findViewById(R.id.lightNum);
            holder.dis = (TextView) convertView.findViewById(R.id.dis);
            convertView.setTag(holder);
        } else {
            holder = (NodeViewHolder) convertView.getTag();
        }

        switch (mtype) {
            case  TRANSIT_ROUTE:
            case WALKING_ROUTE:
            case BIKING_ROUTE:
                holder.name.setText("路线" + (position + 1));
                int time = routeLines.get(position).getDuration();
                if ( time / 3600 == 0 ) {
                    holder.lightNum.setText( "大约需要:" + time / 60 + "分钟" );
                } else {
                    holder.lightNum.setText( "大约需要:" + time / 3600 + "小时" + (time % 3600) / 60 + "分钟" );
                }
                holder.dis.setText("距离大约是:" + routeLines.get(position).getDistance() + "米");
                break;

//            case DRIVING_ROUTE:
//                DrivingRouteLine drivingRouteLine = (DrivingRouteLine) routeLines.get(position);
//                holder.name.setText( "线路" + (position + 1));
//                holder.lightNum.setText( "红绿灯数:" + drivingRouteLine.getLightNum());
//                holder.dis.setText("拥堵距离为:" + drivingRouteLine.getCongestionDistance() + "米");
//                break;
//            case MASS_TRANSIT_ROUTE:
//                MassTransitRouteLine massTransitRouteLine = (MassTransitRouteLine) routeLines.get(position);
//                holder.name.setText("线路" + (position + 1));
//                holder.lightNum.setText( "预计达到时间:" + massTransitRouteLine.getArriveTime() );
//                holder.dis.setText("总票价:" + massTransitRouteLine.getPrice() + "元");
//                break;

            default:
                break;

        }

        return convertView;
    }
 
Example 19
Project: EsperantoRadio   File: EoUdsendelse_frag.java   Source Code and License Vote up 5 votes
private View opretTopView() {
    View v = getLayoutInflater(null).inflate(R.layout.udsendelse_elem0_top, listView, false);
    AQuery aq = new AQuery(v);
    v.setTag(aq);
//    aq.id(R.id.billede).width(billedeBr, false).height(billedeBr, false).image(burl, true, true, billedeBr, 0, null, AQuery.FADE_IN_NETWORK, (float) højde9 / bredde16);
//    aq.id(R.id.billede).width(billedeBr, false).image(burl, true, true, billedeBr, 0, null, AQuery.FADE_IN_NETWORK);

    if (kanal.kode.equals("radioverda")) {
      aq.id(R.id.billede).image("http://radioverda.com/storage/bildoj/programbildoj/"+udsendelse.titel+".png")
          .getImageView().setScaleType(ImageView.ScaleType.CENTER_CROP);
    } else {
      String emblemo = udsendelse.billedeUrl;
      if (emblemo==null || emblemo.length()==0) emblemo = kanal.kanallogo_url;
      aq.id(R.id.billede).image(emblemo)
          .getImageView().setScaleType(ImageView.ScaleType.CENTER_CROP);
    }

//    aq.id(R.id.udsendelse_baggrundsgradient).gone();
    aq.id(R.id.lige_nu).gone();
    aq.id(R.id.info).typeface(App.skrift_gibson);
    aq.id(R.id.kanallogo).gone();
    aq.id(R.id.p4navn).text("");

    if (kanal.eo_montruTitolojn) {
      aq.id(R.id.titel).typeface(App.skrift_gibson_fed).text(udsendelse.titel)
          .getTextView().setContentDescription("\u00A0");  // SLUK for højtlæsning, det varetages af listviewet
    } else {
      aq.id(R.id.titel).gone();
    }

//    .textSize(16).getTextView().setMaxLines(5);
    aq.id(R.id.starttid).typeface(App.skrift_gibson)
        .text(udsendelse.startTid == null ? "" : Datoformater.datoformat.format(udsendelse.startTid))
        .getTextView().setContentDescription("\u00A0");  // SLUK for højtlæsning, det varetages af listviewet
    aq.id(R.id.hør).clicked(this);
    aq.id(R.id.hør_tekst).typeface(App.skrift_gibson);
    aq.id(R.id.hent).clicked(this).typeface(App.skrift_gibson);
    aq.id(R.id.favorit).clicked(this).typeface(App.skrift_gibson).checked(udsendelse.getBackend().favoritter.erFavorit(udsendelse.programserieSlug));
    if (!App.data.hentedeUdsendelser.virker()) aq.gone(); // Understøttes ikke på Android 2.2
    aq.id(R.id.del).clicked(this).typeface(App.skrift_gibson);
    return v;
  }
 
Example 20
Project: Hotspot-master-devp   File: CollectListAdapter.java   Source Code and License Vote up 5 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final ViewHolder holder;
    if (convertView == null) {
        holder = new ViewHolder();
        convertView = mInflater.inflate(R.layout.item_collect, null);

        holder.contentSmallImgIV = (ImageView) convertView.findViewById(R.id.content_small_img);
        holder.contentSmallTitleTV = (TextView) convertView.findViewById(R.id.content_small_title);
        holder.contentSmallSourceTV = (TextView) convertView.findViewById(R.id.content_small_source);
        holder.contentSmallTimeTV = (TextView) convertView.findViewById(R.id.content_small_time);
        holder.contentLengthTV = (TextView) convertView.findViewById(R.id.length);
        ViewGroup.LayoutParams layoutParams = holder.contentSmallImgIV.getLayoutParams();
        float widthInPx = DensityUtil.getWidthInPx(mContext);
        float height = widthInPx*SCAL;
        layoutParams.height = (int) height;
        convertView.setTag(R.id.tag_holder, holder);
    } else {
        holder = (ViewHolder) convertView.getTag(R.id.tag_holder);
    }
    CommonListItem itemVo = getItem(position);
    Glide.with(mContext)
            .load(itemVo.getImageURL())
            .placeholder(R.drawable.kong_mrjz)
            .error(R.drawable.kong_mrjz)
            .crossFade()
            .into(holder.contentSmallImgIV);
    holder.contentSmallTitleTV.setText(itemVo.getTitle());

    String  time = itemVo.getAcreateTime();
   // time=time*1000;
    if (!TextUtils.isEmpty(time)) {
        holder.contentSmallTimeTV.setText(time);
    }


    String sourceName = itemVo.getSourceName();
    if (!TextUtils.isEmpty(sourceName)) {
        holder.contentSmallSourceTV.setText(sourceName);
    }else {
        holder.contentSmallSourceTV.setVisibility(View.GONE);
    }

    /**文章类型  0:纯文本,1:图文,2:图集,3:视频,4:纯视频*/
    int  type = itemVo.getType();
    switch (type){
        case 0:
        case 1:
            holder.contentLengthTV.setVisibility(View.GONE);
            break;
        case 2:
            int colTuJi = itemVo.getColTuJi();
            if (colTuJi > 0) {
                holder.contentLengthTV.setVisibility(View.VISIBLE);
                holder.contentLengthTV.setText(colTuJi+"图");
            }
            break;
        case 3:
        case 4:
            String  duration = itemVo.getDuration();
            if (!TextUtils.isEmpty(duration)) {
                holder.contentLengthTV.setVisibility(View.VISIBLE);
                holder.contentLengthTV.setText(DateUtil.formatSecondsTime(duration));
            }
            break;
    }

    convertView.setOnClickListener(new mStoreListener(itemVo) );
    convertView.setOnLongClickListener(new mLongItemListener(itemVo));
    return convertView;
}