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

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

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

ImageButton.setContentDescription介绍

暂无

代码示例

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

private void setDeckExpander(ImageButton expander, ImageButton indent, Sched.DeckDueTreeNode node){
  boolean collapsed = mCol.getDecks().get(node.did).optBoolean("collapsed", false);
  // Apply the correct expand/collapse drawable
  if (collapsed) {
    expander.setImageDrawable(mExpandImage);
    expander.setContentDescription(expander.getContext().getString(R.string.expand));
  } else if (node.children.size() > 0) {
    expander.setImageDrawable(mCollapseImage);
    expander.setContentDescription(expander.getContext().getString(R.string.collapse));
  } else {
    expander.setImageDrawable(mNoExpander);
  }
  // Add some indenting for each nested level
  int width = (int) indent.getResources().getDimension(R.dimen.keyline_1) * node.depth;
  indent.setMinimumWidth(width);
}

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

setMMButtonListener(mediaButton, i);
mediaButton.setContentDescription(getString(R.string.multimedia_editor_attach_mm_content, fields[i][0]));
mFieldsLayoutContainer.addView(label);
mFieldsLayoutContainer.addView(editline_view);

代码示例来源:origin: googlesamples/android-PictureInPicture

void adjustToggleState() {
  if (mMediaPlayer != null && mMediaPlayer.isPlaying()) {
    mToggle.setContentDescription(getResources().getString(R.string.pause));
    mToggle.setImageResource(R.drawable.ic_pause_64dp);
  } else {
    mToggle.setContentDescription(getResources().getString(R.string.play));
    mToggle.setImageResource(R.drawable.ic_play_arrow_64dp);
  }
}

代码示例来源:origin: google/santa-tracker-android

.drawable
            .common_btn_speaker_on);
muteButton.setContentDescription(
    context.getResources()
        .getString(

代码示例来源:origin: MCMrARM/revolution-irc

public void setExtraButton(int icon, CharSequence contentDesc, OnClickListener listener) {
  mExtraButton.setImageResource(icon);
  mExtraButton.setContentDescription(contentDesc);
  mExtraButton.setOnClickListener(listener);
  mExtraButton.setVisibility(View.VISIBLE);
}

代码示例来源:origin: geniusgithub/AndroidDialer

@Override
public void onSpeakerphoneOn(boolean on) {
  if (on) {
    mPlaybackSpeakerphone.setImageResource(R.drawable.ic_volume_up_24dp);
    // Speaker is now on, tapping button will turn it off.
    mPlaybackSpeakerphone.setContentDescription(
        mContext.getString(R.string.voicemail_speaker_off));
  } else {
    mPlaybackSpeakerphone.setImageResource(R.drawable.ic_volume_down_24dp);
    // Speaker is now off, tapping button will turn it on.
    mPlaybackSpeakerphone.setContentDescription(
        mContext.getString(R.string.voicemail_speaker_on));
  }
}

代码示例来源:origin: google/ringdroid

private void enableDisableButtons() {
  if (mIsPlaying) {
    mPlayButton.setImageResource(android.R.drawable.ic_media_pause);
    mPlayButton.setContentDescription(getResources().getText(R.string.stop));
  } else {
    mPlayButton.setImageResource(android.R.drawable.ic_media_play);
    mPlayButton.setContentDescription(getResources().getText(R.string.play));
  }
}

代码示例来源:origin: googlesamples/android-WatchFace

private void updateComplicationView(ComplicationProviderInfo complicationProviderInfo,
  ImageButton button, ImageView background) {
  if (complicationProviderInfo != null) {
    button.setImageIcon(complicationProviderInfo.providerIcon);
    button.setContentDescription(
      mContext.getString(R.string.edit_complication,
        complicationProviderInfo.appName + " " +
          complicationProviderInfo.providerName));
    background.setVisibility(View.VISIBLE);
  } else {
    button.setImageDrawable(mDefaultComplicationDrawable);
    button.setContentDescription(mContext.getString(R.string.add_complication));
    background.setVisibility(View.INVISIBLE);
  }
}

代码示例来源:origin: ywwynm/EverythingDone

private void initBackButton(@Thing.Type int thingType) {
  if (thingType == Thing.REMINDER || thingType == Thing.WELCOME_REMINDER) {
    mIbBack.setImageResource(R.drawable.act_back_reminder);
    mIbBack.setContentDescription(getString(R.string.cd_back_reminder));
  } else if (thingType == Thing.HABIT || thingType == Thing.WELCOME_HABIT) {
    mIbBack.setImageResource(R.drawable.act_back_habit);
    mIbBack.setContentDescription(getString(R.string.cd_back_habit));
  } else if (thingType == Thing.GOAL || thingType == Thing.WELCOME_GOAL) {
    mIbBack.setImageResource(R.drawable.act_back_goal);
    mIbBack.setContentDescription(getString(R.string.cd_back_goal));
  } else {
    mIbBack.setImageResource(R.drawable.act_back_note);
    mIbBack.setContentDescription(getString(R.string.cd_back_note));
  }
}

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

for (int i = 0; i < RenaissanceDatabase.description[].length; i++) {
   ImageButton btn = new ImageButton(this);
   int id = getResources().getIdentifier("yourpackagename:drawable/painting" + (i+1), null, null);
   btn.setImageDrawable(getResources().getDrawable(
       id));
   btn.setContentDescription(RenaissanceDatabase.description[i]);
   mLinearList.addView(btn);
 }

代码示例来源:origin: geniusgithub/AndroidDialer

public void changeIcon(Drawable icon, String description) {
  if (mFloatingActionButton.getDrawable() != icon
      || !mFloatingActionButton.getContentDescription().equals(description)) {
    mFloatingActionButton.setImageDrawable(icon);
    mFloatingActionButton.setContentDescription(description);
  }
}

代码示例来源:origin: derry/delion

@Override
public void setCustomActionButton(Drawable drawable, String description,
    OnClickListener listener) {
  Resources resources = getResources();
  // The height will be scaled to match spec while keeping the aspect ratio, so get the scaled
  // width through that.
  int sourceHeight = drawable.getIntrinsicHeight();
  int sourceScaledHeight = resources.getDimensionPixelSize(R.dimen.toolbar_icon_height);
  int sourceWidth = drawable.getIntrinsicWidth();
  int sourceScaledWidth = sourceWidth * sourceScaledHeight / sourceHeight;
  int minPadding = resources.getDimensionPixelSize(R.dimen.min_toolbar_icon_side_padding);
  int sidePadding = Math.max((2 * sourceScaledHeight - sourceScaledWidth) / 2, minPadding);
  int topPadding = mCustomActionButton.getPaddingTop();
  int bottomPadding = mCustomActionButton.getPaddingBottom();
  mCustomActionButton.setPadding(sidePadding, topPadding, sidePadding, bottomPadding);
  mCustomActionButton.setImageDrawable(drawable);
  mCustomActionButton.setContentDescription(description);
  mCustomActionButton.setOnClickListener(listener);
  mCustomActionButton.setVisibility(VISIBLE);
  updateButtonsTint();
}

代码示例来源:origin: AlexMofer/ProjectX

void setOverflow(boolean animate) {
  if (animate && mBackToOverflow != null) {
    mButton.setImageDrawable(mBackToOverflow);
    if (mBackToOverflow instanceof Animatable)
      ((Animatable) mBackToOverflow).start();
  } else {
    mButton.setImageDrawable(mOverflow);
  }
  mButton.setContentDescription(mOverflowContentDescription);
}

代码示例来源:origin: AlexMofer/ProjectX

void setBack(boolean animate) {
  if (animate && mOverflowToBack != null) {
    mButton.setImageDrawable(mOverflowToBack);
    if (mOverflowToBack instanceof Animatable)
      ((Animatable) mOverflowToBack).start();
  } else {
    mButton.setImageDrawable(mBack);
  }
  mButton.setContentDescription(mBackContentDescription);
}

代码示例来源:origin: ybonnel/TransportsRennes

actionButton.setImageDrawable(icon);
actionButton.setScaleType(ImageView.ScaleType.CENTER);
actionButton.setContentDescription(title);
actionButton.setOnClickListener(clickListener);

代码示例来源:origin: ywwynm/EverythingDone

@Override
  public void onCancel() {
    mIbBack.setImageResource(R.drawable.act_back_goal);
    mIbBack.setContentDescription(getString(R.string.cd_back_goal));
    cbQuickRemind.setChecked(true);
    quickRemindPicker.pickForUI(9);
    rhParams.reset();
    long reminderInMillis = mReminder.getNotifyTime();
    rhParams.setReminderInMillis(reminderInMillis);
    tvQuickRemind.setText(DateTimeUtil.getDateTimeStrAt(
        reminderInMillis, DetailActivity.this, false));
  }
});

代码示例来源:origin: cbeyls/fosdem-companion-android

@Override
  public void onChanged(BookmarkStatus bookmarkStatus) {
    if (bookmarkStatus == null) {
      imageButton.setEnabled(false);
      imageButton.setImageResource(R.drawable.ic_bookmark_outline_white_24dp);
    } else {
      // Only animate updates, when the button was already enabled
      final boolean animate = bookmarkStatus.isUpdate() && imageButton.isEnabled();
      imageButton.setEnabled(true);
      if (bookmarkStatus.isBookmarked()) {
        imageButton.setContentDescription(imageButton.getContext().getString(R.string.remove_bookmark));
        imageButton.setImageResource(animate ? R.drawable.avd_bookmark_add_24dp : R.drawable.ic_bookmark_white_24dp);
      } else {
        imageButton.setContentDescription(imageButton.getContext().getString(R.string.add_bookmark));
        imageButton.setImageResource(animate ? R.drawable.avd_bookmark_remove_24dp : R.drawable.ic_bookmark_outline_white_24dp);
      }
      final Drawable drawable = imageButton.getDrawable();
      if (drawable instanceof Animatable) {
        ((Animatable) drawable).start();
      }
    }
  }
});

代码示例来源:origin: derry/delion

@Override
protected void updateTabCountVisuals(int numberOfTabs) {
  mAccessibilitySwitcherButton.setContentDescription(
      getResources().getString(R.string.accessibility_toolbar_btn_tabswitcher_toggle,
          numberOfTabs));
  mTabSwitcherButtonDrawable.updateForTabCount(numberOfTabs, isIncognito());
  mTabSwitcherButtonDrawableLight.updateForTabCount(numberOfTabs, isIncognito());
}

代码示例来源:origin: derry/delion

/**
 * Updates the custom buttons on bottom bar area.
 * @param params The {@link CustomButtonParams} that describes the button to update.
 */
public void updateBottomBarButtons(CustomButtonParams params) {
  ImageButton button = (ImageButton) getBottomBarView().findViewById(params.getId());
  button.setContentDescription(params.getDescription());
  button.setImageDrawable(params.getIcon(mActivity.getResources()));
}

代码示例来源:origin: ywwynm/EverythingDone

@Override
  public void onCancel() {
    mIbBack.setImageResource(R.drawable.act_back_habit);
    mIbBack.setContentDescription(getString(R.string.cd_back_habit));
    cbQuickRemind.setChecked(true);
    quickRemindPicker.pickForUI(9);
    rhParams.reset();
    int habitType = mHabit.getType();
    String habitDetail = mHabit.getDetail();
    rhParams.setHabitType(habitType);
    rhParams.setHabitDetail(habitDetail);
    tvQuickRemind.setText(DateTimeUtil.getDateTimeStrRec(
        mApp, habitType, habitDetail));
  }
});

相关文章

ImageButton类方法