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

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

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

ImageButton.setImageResource介绍

暂无

代码示例

代码示例来源:origin: frogermcs/InstaMaterial

@Override
public void onAnimationStart(Animator animation) {
  holder.btnLike.setImageResource(R.drawable.ic_heart_red);
}

代码示例来源:origin: TeamNewPipe/NewPipe

protected void setRepeatModeButton(final ImageButton imageButton, final int repeatMode) {
  switch (repeatMode) {
    case Player.REPEAT_MODE_OFF:
      imageButton.setImageResource(R.drawable.exo_controls_repeat_off);
      break;
    case Player.REPEAT_MODE_ONE:
      imageButton.setImageResource(R.drawable.exo_controls_repeat_one);
      break;
    case Player.REPEAT_MODE_ALL:
      imageButton.setImageResource(R.drawable.exo_controls_repeat_all);
      break;
  }
}

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

ImageButton btn = (ImageButton)findViewById(R.id.button1);
btn.setImageResource(R.drawable.newimage);

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

ImageButton Demo_button = (ImageButton)findViewById(R.id.firstimage);

// when you click this demo button
Demo_button.setOnClickListener(new OnClickListener() {
  public void onClick(View v) {
    Demo_button.setImageResource(R.drawable.secondimage);
  }
}

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

ImageButton btn = (ImageButton)findViewById(R.id.imageButton1);       
btn.setImageResource(R.drawable.actions_record);

代码示例来源:origin: pili-engineering/PLDroidPlayer

private void updatePausePlay() {
  if (mRoot == null || mPauseButton == null)
    return;
  if (mPlayer.isPlaying())
    mPauseButton.setImageResource(IC_MEDIA_PAUSE_ID);
  else
    mPauseButton.setImageResource(IC_MEDIA_PLAY_ID);
}

代码示例来源:origin: hidroh/materialistic

private void setProgress(int progress) {
  mProgressBar.setProgress(progress);
  mProgressBar.setVisibility(progress == 100 ? GONE : VISIBLE);
  mButtonRefresh.setImageResource(progress == 100 ?
      R.drawable.ic_refresh_white_24dp : R.drawable.ic_clear_white_24dp);
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

private void updatePausePlay() {
  if (mRoot == null || mPauseButton == null || mTvPlay == null) {
    return;
  }
  if (mPlayer.isPlaying()) {
    mPauseButton.setImageResource(R.drawable.bili_player_play_can_pause);
    mTvPlay.setImageResource(R.drawable.ic_tv_stop);
  } else {
    mPauseButton.setImageResource(R.drawable.bili_player_play_can_play);
    mTvPlay.setImageResource(R.drawable.ic_tv_play);
  }
}

代码示例来源:origin: koral--/android-gif-drawable

private void postInit(GifViewUtils.GifImageViewAttributes result) {
  mFreezesAnimation = result.freezesAnimation;
  if (result.mSourceResId > 0) {
    super.setImageResource(result.mSourceResId);
  }
  if (result.mBackgroundResId > 0) {
    super.setBackgroundResource(result.mBackgroundResId);
  }
}

代码示例来源:origin: koral--/android-gif-drawable

@Override
public void setImageResource(int resId) {
  if (!GifViewUtils.setResource(this, true, resId)) {
    super.setImageResource(resId);
  }
}

代码示例来源:origin: TeamNewPipe/NewPipe

private void onPlayModeChanged(final int repeatMode, final boolean shuffled) {
  switch (repeatMode) {
    case Player.REPEAT_MODE_OFF:
      repeatButton.setImageResource(R.drawable.exo_controls_repeat_off);
      break;
    case Player.REPEAT_MODE_ONE:
      repeatButton.setImageResource(R.drawable.exo_controls_repeat_one);
      break;
    case Player.REPEAT_MODE_ALL:
      repeatButton.setImageResource(R.drawable.exo_controls_repeat_all);
      break;
  }
  final int shuffleAlpha = shuffled ? 255 : 77;
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
    shuffleButton.setImageAlpha(shuffleAlpha);
  } else {
    shuffleButton.setAlpha(shuffleAlpha);
  }
}

代码示例来源:origin: TeamNewPipe/NewPipe

private void onStateChanged(final int state) {
  switch (state) {
    case BasePlayer.STATE_PAUSED:
      playPauseButton.setImageResource(R.drawable.ic_play_arrow_white);
      break;
    case BasePlayer.STATE_PLAYING:
      playPauseButton.setImageResource(R.drawable.ic_pause_white);
      break;
    case BasePlayer.STATE_COMPLETED:
      playPauseButton.setImageResource(R.drawable.ic_replay_white);
      break;
    default:
      break;
  }
  switch (state) {
    case BasePlayer.STATE_PAUSED:
    case BasePlayer.STATE_PLAYING:
    case BasePlayer.STATE_COMPLETED:
      playPauseButton.setClickable(true);
      playPauseButton.setVisibility(View.VISIBLE);
      progressBar.setVisibility(View.GONE);
      break;
    default:
      playPauseButton.setClickable(false);
      playPauseButton.setVisibility(View.INVISIBLE);
      progressBar.setVisibility(View.VISIBLE);
      break;
  }
}

代码示例来源:origin: frogermcs/InstaMaterial

public void bindView(FeedItem feedItem) {
  this.feedItem = feedItem;
  int adapterPosition = getAdapterPosition();
  ivFeedCenter.setImageResource(adapterPosition % 2 == 0 ? R.drawable.img_feed_center_1 : R.drawable.img_feed_center_2);
  ivFeedBottom.setImageResource(adapterPosition % 2 == 0 ? R.drawable.img_feed_bottom_1 : R.drawable.img_feed_bottom_2);
  btnLike.setImageResource(feedItem.isLiked ? R.drawable.ic_heart_red : R.drawable.ic_heart_outline_grey);
  tsLikesCounter.setCurrentText(vImageRoot.getResources().getQuantityString(
      R.plurals.likes_count, feedItem.likesCount, feedItem.likesCount
  ));
}

代码示例来源:origin: GitLqr/LQRWeChat

@Override
public void initView() {
  mIbToolbarMore.setImageResource(R.mipmap.ic_session_info);
  mIbToolbarMore.setVisibility(View.VISIBLE);
  mElEmotion.attachEditText(mEtContent);
  initEmotionKeyboard();
  initRefreshLayout();
  setTitle();
}

代码示例来源:origin: JohnPersano/SuperToasts

private void addIconTab(final int position, int resId) {
  ImageButton tab = new ImageButton(getContext());
  tab.setImageResource(resId);
  addTab(position, tab);
}

代码示例来源:origin: joyoyao/superCleanMaster

private void addIconTab(final int position, int resId) {
  ImageButton tab = new ImageButton(getContext());
  tab.setImageResource(resId);
  addTab(position, tab);
}

代码示例来源:origin: TeamNewPipe/NewPipe

@Override
public void onBlocked() {
  super.onBlocked();
  playPauseButton.setImageResource(R.drawable.ic_pause_white);
  animatePlayButtons(false, 100);
  getRootView().setKeepScreenOn(true);
}

代码示例来源:origin: TeamNewPipe/NewPipe

@Override
public void onCompleted() {
  animateView(playPauseButton, AnimationUtils.Type.SCALE_AND_ALPHA, false, 0, 0, () -> {
    playPauseButton.setImageResource(R.drawable.ic_replay_white);
    animatePlayButtons(true, DEFAULT_CONTROLS_DURATION);
  });
  getRootView().setKeepScreenOn(false);
  super.onCompleted();
}

代码示例来源:origin: TeamNewPipe/NewPipe

@Override
public void onPlaying() {
  super.onPlaying();
  animateView(playPauseButton, AnimationUtils.Type.SCALE_AND_ALPHA, false, 80, 0, () -> {
    playPauseButton.setImageResource(R.drawable.ic_pause_white);
    animatePlayButtons(true, 200);
  });
  getRootView().setKeepScreenOn(true);
}

代码示例来源:origin: TeamNewPipe/NewPipe

@Override
public void onPaused() {
  super.onPaused();
  animateView(playPauseButton, AnimationUtils.Type.SCALE_AND_ALPHA, false, 80, 0, () -> {
    playPauseButton.setImageResource(R.drawable.ic_play_arrow_white);
    animatePlayButtons(true, 200);
  });
  showSystemUi();
  getRootView().setKeepScreenOn(false);
}

相关文章

ImageButton类方法