android.widget.ImageButton.setTag()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中android.widget.ImageButton.setTag()方法的一些代码示例,展示了ImageButton.setTag()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageButton.setTag()方法的具体详情如下:
包路径:android.widget.ImageButton
类名称:ImageButton
方法名:setTag

ImageButton.setTag介绍

暂无

代码示例

代码示例来源:origin: mxn21/FlowingDrawer

private void bindDefaultFeedItem(int position, CellFeedViewHolder holder) {
  if (position % 2 == 0) {
    holder.ivFeedCenter.setImageResource(R.drawable.img_feed_center_1);
    holder.ivFeedBottom.setImageResource(R.drawable.img_feed_bottom_1);
  } else {
    holder.ivFeedCenter.setImageResource(R.drawable.img_feed_center_2);
    holder.ivFeedBottom.setImageResource(R.drawable.img_feed_bottom_2);
  }
  holder.btnComments.setTag(position);
  holder.btnMore.setTag(position);
  holder.ivFeedCenter.setTag(holder);
  holder.btnLike.setTag(holder);
}

代码示例来源:origin: ankidroid/Anki-Android

@Override
public void onBindViewHolder(@NonNull ButtonVH holder, int position) {
  holder.title.setText(items.get(position));
  holder.button.setTag(items.get(position));
}

代码示例来源:origin: ankidroid/Anki-Android

holder.deckExpander.setTag(node.did);
  holder.deckExpander.setOnClickListener(mDeckExpanderClickListener);
} else {

代码示例来源:origin: michael-rapp/ChromeLikeTabSwitcher

/**
 * Adapts the visibility of a tab's close button.
 *
 * @param tabItem
 *         The tab item, which corresponds to the tab, whose close button should be adapted, as
 *         an instance of the class {@link TabItem}. The tab item may not be null
 */
private void adaptCloseButtonVisibility(@NonNull final TabItem tabItem) {
  Tab tab = tabItem.getTab();
  AbstractTabViewHolder viewHolder = tabItem.getViewHolder();
  viewHolder.closeButton.setVisibility(tab.isCloseable() ? View.VISIBLE : View.GONE);
  viewHolder.closeButton.setTag(R.id.tag_visibility, tab.isCloseable());
  viewHolder.closeButton.setOnClickListener(
      tab.isCloseable() ? createCloseButtonClickListener(viewHolder.closeButton, tab) :
          null);
}

代码示例来源:origin: michael-rapp/ChromeLikeTabSwitcher

/**
 * Animates the visibility of a tab's close button.
 *
 * @param viewHolder
 *         The view holder, which holds a reference to the close button, whose visibility should
 *         be animated, as an instance of the class {@link AbstractTabViewHolder}. The view
 *         holder may not be null
 * @param show
 *         True, if the close button should be shown, false otherwise
 */
private void animateCloseButtonVisibility(@NonNull final AbstractTabViewHolder viewHolder,
                     final boolean show) {
  ImageButton closeButton = viewHolder.closeButton;
  Boolean visible = (Boolean) closeButton.getTag(R.id.tag_visibility);
  if (visible == null || visible != show) {
    closeButton.setTag(R.id.tag_visibility, show);
    if (closeButton.getAnimation() != null) {
      closeButton.getAnimation().cancel();
    }
    ViewPropertyAnimator animation = closeButton.animate();
    animation.setListener(createCloseButtonVisibilityAnimationListener(viewHolder, show));
    animation.alpha(show ? 1 : 0);
    animation.setStartDelay(0);
    animation.setDuration(closeButtonVisibilityAnimationDuration);
    animation.start();
  }
}

代码示例来源:origin: stackoverflow.com

public void Images(View v)
{
ImageButton i = (ImageButton) v;
i.setImageResource(R.drawable.c4_pressed_button);
i.setTag("R.drawable.c4_pressed_button");
}

代码示例来源:origin: stackoverflow.com

TextView textView = ((TextView)  view.findViewById(R.id.textListView)).setText(item.getNome());
 ImageButton ib = (ImageButton) view.findViewById(R.id.imageButton1);
 ib.setOnClickListener(this);
  ib.setTag(textView);

代码示例来源:origin: xbmc/Kore

private void setupToggleButton(final ImageButton button, final View.OnClickListener listener) {
  button.setVisibility(View.VISIBLE);
  button.setTag(false);
  button.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
      listener.onClick(view);
      // Boldly invert the state. We depend on the observer to correct the state
      // if Kodi or other service didn't honour our request
      setToggleButtonState(button, ! (boolean) button.getTag());
    }
  });
}

代码示例来源:origin: stackoverflow.com

@Override
public View getView( int position, View convertView, ViewGroup parent) {
  View v = null;

  if( convertView != null )
    v = convertView;
  else
    v = inflater.inflate( R.layout.add_program_ex_list_item, parent, false);
  ImageButton button = (ImageButton) v
      .findViewById(R.id.add_program_exercise_list);
  button.setTag(position);
  button.setOnClickListener(this); 

  return v;
}

代码示例来源:origin: stackoverflow.com

@Override
public View getView(int position, View convertView, ViewGroup parent) {
  ImageButton ib = ...
  ib.setTag(new Integer(position));
  ib.setOnClickListener(myListener);
}

....

private OnClickListener myListener = new OnClickListener() {
  @Override
  public void onClick(View v) {
    int position = v.getTag(v.intValue());
  }
};

代码示例来源:origin: UdacityAndroidDevScholarship/gis-2k18

public QuizAnnouncementsViewHolder(View itemView) {
    super(itemView);
    shareQuiz = itemView.findViewById(R.id.ib_share_quiz);
    openInBrowser = itemView.findViewById(R.id.ib_open_quiz);
    bookmarkQuiz = itemView.findViewById(R.id.ib_bookmark_quiz);
    bookmarkQuiz.setTag(UNBOOKMARKED);
  }
}

代码示例来源:origin: UdacityAndroidDevScholarship/gis-2k18

public BlogsViewHolder(View itemView) {
    super(itemView);
    bookmark = (ImageButton) itemView.findViewById(R.id.ib_bookmark_blog);
    share = (ImageButton) itemView.findViewById(R.id.ib_share_blog);
    openInBrowser = (ImageButton) itemView.findViewById(R.id.ib_open_blog);
    thumbnailImage = (ImageView) itemView.findViewById(R.id.img_view_blog_thumbnail);
    bookmark.setTag(UNBOOKMARKED);
  }
}

代码示例来源:origin: stackoverflow.com

public void onFavClick(ImageButton favourite) {
   if ((Integer)favourite.getTag() == R.drawable.ic_star_border_black_18dp){ 
     favourite.setImageResource(R.drawable.ic_star_black_18dp);
     favourite.setTag(R.drawable.ic_star_black_18dp); }
  } else{ 
     favourite.setImageResource(R.drawable.ic_star_border_black_18dp); 
      favourite.setTag(R.drawable.ic_star_border_black_18dp); }
 } }

代码示例来源:origin: stackoverflow.com

@Override
public View getView (int position, View convertView, ViewGroup parent) {
  View v = null;
  if (convertView != null)
    v = convertView;
  else
    v = inflater.inflate( R.layout.add_program_ex_list_item, parent, false);

  TextView textView = (TextView) v.findViewById(R.id.your_text_view);
  textView.setText(getItem(position));

  ImageButton button = (ImageButton) v.findViewById(R.id.add_program_exercise_list);
  button.setTag(position);
  button.setOnClickListener(this); 

  return v;
}

代码示例来源:origin: UdacityAndroidDevScholarship/gis-2k18

@Override
  public void onClick(View view) {
    if(holder.bookmark.getTag().equals(UNBOOKMARKED)){
      holder.bookmark.setTag(BOOKMARKED);
      holder.bookmark.setImageResource(R.drawable.ic_bookmark_checked);
      Toast.makeText(mContext, "Blog " + BOOKMARKED, Toast.LENGTH_SHORT).show();
    }
    else{
      holder.bookmark.setTag(UNBOOKMARKED);
      holder.bookmark.setImageResource(R.drawable.ic_bookmark);
      Toast.makeText(mContext, "Blog " + UNBOOKMARKED, Toast.LENGTH_SHORT).show();
    }
  }
});

代码示例来源:origin: stackoverflow.com

public void createButtonsAndAddListener() {
  LinearLayout parent = (LinearLayout) findViewById(R.id.ll);
  for (int i = 0; i < 10; i++) {
    ImageButton imageButton = new ImageButton(this);
    imageButton.setImageResource(R.drawable.mybutton);
    imageButton.setTag(i);
    allImageButtons[i] = imageButton;
    allImageButtons[i].setOnClickListener(click);
    parent.addView(imageButton);

  }
}

代码示例来源:origin: UdacityAndroidDevScholarship/gis-2k18

@Override
  public void onClick(View view) {
    if(holder.bookmarkQuiz.getTag().equals(UNBOOKMARKED)){
      holder.bookmarkQuiz.setTag(BOOKMARKED);
      holder.bookmarkQuiz.setImageResource(R.drawable.ic_bookmark_checked);
      Toast.makeText(mContext, "Quiz " + BOOKMARKED, Toast.LENGTH_SHORT).show();
    }
    else{
      holder.bookmarkQuiz.setTag(UNBOOKMARKED);
      holder.bookmarkQuiz.setImageResource(R.drawable.ic_bookmark);
      Toast.makeText(mContext, "Quiz " + UNBOOKMARKED, Toast.LENGTH_SHORT).show();
    }
  }
});

代码示例来源:origin: souch/SMP

private void stopPlayButton() {
  duration.setVisibility(TextView.INVISIBLE);
  seekbar.setVisibility(TextView.INVISIBLE);
  currDuration.setText(R.string.app_name);
  playButton.setImageResource(R.drawable.ic_action_play);
  playButton.setTag(R.drawable.ic_action_play);
}

代码示例来源:origin: stackoverflow.com

@Override
  public View getView(int position, View convertView, ViewGroup parent) {

    convertView = inflater.inflate(R.layout.list_row, null);

  TextView proverb = (TextView) convertView.findViewById(R.id.title);
  proverb.setText(data.get(position));
  proverb.setTextSize(android.util.TypedValue.COMPLEX_UNIT_SP, 14);
  proverb.setTypeface(MainActivity.tf, 1);
  ImageButton favBtn = (ImageButton) convertView.findViewById(R.id.btn_favorite);
  if(MainActivity.favorites.contains(data.get(position))){
    // favorite, set fav icon
    favBtn.setImageDrawable(myActivity.getResources().getDrawable(R.drawable.fav));         
  }       
  favBtn.setTag(position);
  return convertView;
}

代码示例来源:origin: xbmc/Kore

private void setToggleButtonState(ImageButton button, boolean state) {
  UIUtils.highlightImageView(getActivity(), button, state);
  button.setTag(state);
}

相关文章

ImageButton类方法