Java 类android.support.v7.widget.TooltipCompat 实例源码

项目:StudyBuddy    文件:StudyAdapter.java   
@Override
    public void onBindViewHolder(final StudyAdapter.Holder holder, final int position) {
        TaskItem item = mFeedItemList.get(position);
        TextView textView = holder.textView;
        textView.setText(item.getTaskName());
        ImageButton imgBtn = holder.markDoneBtn;
        TooltipCompat.setTooltipText(imgBtn, "Mark as done");
//        imgBtn.setTooltipText() = TooltipCompat.setTooltipText();
//        imgBtn.setTooltipText(test);
        imgBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                notifyItemRemoved(position);
                mFeedItemList.remove(position);
                Snackbar.make(view, "Task marked as done.", 6000).show();
            }
        });
    }
项目:material-components-android    文件:NavigationMenuItemView.java   
@Override
public void initialize(MenuItemImpl itemData, int menuType) {
  this.itemData = itemData;

  setVisibility(itemData.isVisible() ? VISIBLE : GONE);

  if (getBackground() == null) {
    ViewCompat.setBackground(this, createDefaultBackground());
  }

  setCheckable(itemData.isCheckable());
  setChecked(itemData.isChecked());
  setEnabled(itemData.isEnabled());
  setTitle(itemData.getTitle());
  setIcon(itemData.getIcon());
  setActionView(itemData.getActionView());
  setContentDescription(itemData.getContentDescription());
  TooltipCompat.setTooltipText(this, itemData.getTooltipText());
  adjustAppearance();
}
项目:mvvm-template    文件:AvatarLayout.java   
public void bindData(GlideLoader glideLoader, @Nullable User user) {
    this.user = user;
    if (user != null) {
        avatar.setContentDescription(user.getLogin());
        TooltipCompat.setTooltipText(avatar, user.getLogin());
        glideLoader.loadImage(user.getAvatarUrl(), avatar);
    } else {
        avatar.setImageResource(R.drawable.ic_github);
    }
}
项目:material-components-android    文件:BottomNavigationItemView.java   
@Override
public void initialize(MenuItemImpl itemData, int menuType) {
  this.itemData = itemData;
  setCheckable(itemData.isCheckable());
  setChecked(itemData.isChecked());
  setEnabled(itemData.isEnabled());
  setIcon(itemData.getIcon());
  setTitle(itemData.getTitle());
  setId(itemData.getItemId());
  setContentDescription(itemData.getContentDescription());
  TooltipCompat.setTooltipText(this, itemData.getTooltipText());
  setVisibility(itemData.isVisible() ? View.VISIBLE : View.GONE);
}
项目:mvvm-template    文件:ForegroundImageView.java   
public ForegroundImageView(@NonNull Context context, AttributeSet attrs) {
    this(context, attrs, 0);
    if (getContentDescription() != null) {
        TooltipCompat.setTooltipText(this, getContentDescription());
    }
}
项目:material-components-android    文件:TabLayout.java   
private void updateTextAndIcon(
    @Nullable final TextView textView, @Nullable final ImageView iconView) {
  final Drawable icon =
      (tab != null && tab.getIcon() != null)
          ? DrawableCompat.wrap(tab.getIcon()).mutate()
          : null;
  final CharSequence text = tab != null ? tab.getText() : null;
  final CharSequence contentDesc = tab != null ? tab.getContentDescription() : null;

  if (iconView != null) {
    if (icon != null) {
      DrawableCompat.setTintList(icon, tabIconTint);
      if (tabIconTintMode != null) {
        DrawableCompat.setTintMode(icon, tabIconTintMode);
      }
      iconView.setImageDrawable(icon);
      iconView.setVisibility(VISIBLE);
      setVisibility(VISIBLE);
    } else {
      iconView.setVisibility(GONE);
      iconView.setImageDrawable(null);
    }
    iconView.setContentDescription(contentDesc);
  }

  final boolean hasText = !TextUtils.isEmpty(text);
  if (textView != null) {
    if (hasText) {
      textView.setText(text);
      textView.setVisibility(VISIBLE);
      setVisibility(VISIBLE);
    } else {
      textView.setVisibility(GONE);
      textView.setText(null);
    }
    textView.setContentDescription(contentDesc);
  }

  if (iconView != null) {
    MarginLayoutParams lp = ((MarginLayoutParams) iconView.getLayoutParams());
    int iconMargin = 0;
    if (hasText && iconView.getVisibility() == VISIBLE) {
      // If we're showing both text and icon, add some margin bottom to the icon
      iconMargin = dpToPx(DEFAULT_GAP_TEXT_ICON);
    }
    if (inlineLabel) {
      if (iconMargin != MarginLayoutParamsCompat.getMarginEnd(lp)) {
        MarginLayoutParamsCompat.setMarginEnd(lp, iconMargin);
        lp.bottomMargin = 0;
        // Calls resolveLayoutParams(), necessary for layout direction
        iconView.setLayoutParams(lp);
        iconView.requestLayout();
      }
    } else {
      if (iconMargin != lp.bottomMargin) {
        lp.bottomMargin = iconMargin;
        MarginLayoutParamsCompat.setMarginEnd(lp, 0);
        // Calls resolveLayoutParams(), necessary for layout direction
        iconView.setLayoutParams(lp);
        iconView.requestLayout();
      }
    }
  }

  TooltipCompat.setTooltipText(this, hasText ? null : contentDesc);
}
项目:TwistyTimer    文件:TimerGraphFragment.java   
/**
 * Since all stats views have the same base layout, they share the same views
 * with the same ids. This function uses the TooltipCompat function added in support library
 * v26 to set a tooltip for an icon in each of the stats tabs.
 *
 * @param viewId
 *      The ID of the view that should receive the tooltip
 * @param tooltipTextRes
 *      The string resource to be displayed
 */
private void setTooltipText(@IdRes int viewId, @StringRes int tooltipTextRes) {
    TooltipCompat.setTooltipText(statsImprovementLayout.findViewById(viewId),
            getString(tooltipTextRes));
    TooltipCompat.setTooltipText(statsAverageLayout.findViewById(viewId),
            getString(tooltipTextRes));
    TooltipCompat.setTooltipText(statsOtherlayout.findViewById(viewId),
            getString(tooltipTextRes));
}