当前位置: 首页>>代码示例>>Java>>正文


Java StrikethroughSpan类代码示例

本文整理汇总了Java中android.text.style.StrikethroughSpan的典型用法代码示例。如果您正苦于以下问题:Java StrikethroughSpan类的具体用法?Java StrikethroughSpan怎么用?Java StrikethroughSpan使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StrikethroughSpan类属于android.text.style包,在下文中一共展示了StrikethroughSpan类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getView

import android.text.style.StrikethroughSpan; //导入依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = inflater.inflate(android.R.layout.simple_list_item_multiple_choice,
                parent, false);
    }

    TodoItem item = getItem(position);
    CheckedTextView textView = (CheckedTextView) convertView;
    textView.setChecked(item.complete());

    CharSequence description = item.description();
    if (item.complete()) {
        SpannableString spannable = new SpannableString(description);
        spannable.setSpan(new StrikethroughSpan(), 0, description.length(), 0);
        description = spannable;
    }

    textView.setText(description);

    return convertView;
}
 
开发者ID:geralt-encore,项目名称:Delightful-SQLBrite,代码行数:23,代码来源:ItemsAdapter.java

示例2: setStrikethrough

import android.text.style.StrikethroughSpan; //导入依赖的package包/类
private void setStrikethrough(SpannableStringBuilder builder) {
    final int offset = "[[d[".length(); // == "]d]]".length()

    int start = -1;
    int end;

    for (int i = 0; i < builder.length() - 3; i++) {
        if (builder.charAt(i) == '['
                && builder.charAt(i + 1) == '['
                && builder.charAt(i + 2) == 'd'
                && builder.charAt(i + 3) == '[') {
            start = i + offset;
        } else if (builder.charAt(i) == ']'
                && builder.charAt(i + 1) == 'd'
                && builder.charAt(i + 2) == ']'
                && builder.charAt(i + 3) == ']') {
            end = i;
            builder.setSpan(new StrikethroughSpan(), start, end,
                    Spanned.SPAN_INCLUSIVE_INCLUSIVE);
            builder.delete(end, end + offset);
            builder.delete(start - offset, start);
            i -= offset + (end - start); // length of text
        }
    }
}
 
开发者ID:ccrama,项目名称:Slide-RSS,代码行数:26,代码来源:SpoilerRobotoTextView.java

示例3: setMidLine

import android.text.style.StrikethroughSpan; //导入依赖的package包/类
/**
 * 中横线,即删除线
 *
 * @param isMidLine isMidLine
 */
void setMidLine(boolean isMidLine) {
    int index = getSelectionIndex();
    if (index >= 0 && index < mSections.size()) {
        mSections.get(index).setMidLine(isMidLine);
    }
    Editable edit = getEditableText();
    int star = getSectionStart();
    int end = getSectionEnd();
    if (isMidLine) {
        edit.setSpan(new StrikethroughSpan(),
                star,
                end,
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    } else {
        StrikethroughSpan[] styleSpans = edit.getSpans(star,
                end, StrikethroughSpan.class);
        for (StrikethroughSpan span : styleSpans) {
            edit.removeSpan(span);
        }
    }
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:27,代码来源:RichEditText.java

示例4: endCssStyle

import android.text.style.StrikethroughSpan; //导入依赖的package包/类
private void endCssStyle(String tag, Editable text) {
    Strikethrough s = getLast(text, Strikethrough.class);
    if (s != null) {
        setSpanFromMark(tag, text, s, new StrikethroughSpan());
    }
    Background b = getLast(text, Background.class);
    if (b != null) {
        setSpanFromMark(tag, text, b, new BackgroundColorSpan(b.mBackgroundColor));
    }
    Foreground f = getLast(text, Foreground.class);
    if (f != null) {
        setSpanFromMark(tag, text, f, new ForegroundColorSpan(f.mForegroundColor));
    }
    AbsoluteSize a = getLast(text, AbsoluteSize.class);
    if (a != null) {
        setSpanFromMark(tag, text, a, new AbsoluteSizeSpan(a.getTextSize()));
    }
    RelativeSize r = getLast(text, RelativeSize.class);
    if (r != null) {
        setSpanFromMark(tag, text, r, new RelativeSizeSpan(r.getTextProportion()));
    }
}
 
开发者ID:Pixplicity,项目名称:HtmlCompat,代码行数:23,代码来源:HtmlToSpannedConverter.java

示例5: getView

import android.text.style.StrikethroughSpan; //导入依赖的package包/类
@Override public View getView(int position, View convertView, ViewGroup parent) {
  if (convertView == null) {
    convertView = inflater.inflate(android.R.layout.simple_list_item_multiple_choice, parent, false);
  }

  TodoItem item = getItem(position);
  CheckedTextView textView = (CheckedTextView) convertView;
  textView.setChecked(item.complete());

  CharSequence description = item.description();
  if (item.complete()) {
    SpannableString spannable = new SpannableString(description);
    spannable.setSpan(new StrikethroughSpan(), 0, description.length(), 0);
    description = spannable;
  }

  textView.setText(description);

  return convertView;
}
 
开发者ID:jiechic,项目名称:sqlbrite-sqlcipher,代码行数:21,代码来源:ItemsAdapter.java

示例6: testTextDecorationLineUnderlineApplied

import android.text.style.StrikethroughSpan; //导入依赖的package包/类
@Test
public void testTextDecorationLineUnderlineApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline"),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  TextView textView = (TextView) rootView.getChildAt(0);
  Spanned text = (Spanned) textView.getText();
  UnderlineSpan underlineSpan = getSingleSpan(textView, UnderlineSpan.class);
  StrikethroughSpan[] strikeThroughSpans =
      text.getSpans(0, text.length(), StrikethroughSpan.class);
  assertThat(underlineSpan instanceof UnderlineSpan).isTrue();
  assertThat(strikeThroughSpans).hasSize(0);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:18,代码来源:ReactTextTest.java

示例7: testTextDecorationLineLineThroughApplied

import android.text.style.StrikethroughSpan; //导入依赖的package包/类
@Test
public void testTextDecorationLineLineThroughApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "line-through"),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  TextView textView = (TextView) rootView.getChildAt(0);
  Spanned text = (Spanned) textView.getText();
  UnderlineSpan[] underlineSpans =
      text.getSpans(0, text.length(), UnderlineSpan.class);
  StrikethroughSpan strikeThroughSpan =
      getSingleSpan(textView, StrikethroughSpan.class);
  assertThat(underlineSpans).hasSize(0);
  assertThat(strikeThroughSpan instanceof StrikethroughSpan).isTrue();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:19,代码来源:ReactTextTest.java

示例8: testTextDecorationLineUnderlineLineThroughApplied

import android.text.style.StrikethroughSpan; //导入依赖的package包/类
@Test
public void testTextDecorationLineUnderlineLineThroughApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline line-through"),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  UnderlineSpan underlineSpan =
      getSingleSpan((TextView) rootView.getChildAt(0), UnderlineSpan.class);
  StrikethroughSpan strikeThroughSpan =
      getSingleSpan((TextView) rootView.getChildAt(0), StrikethroughSpan.class);
  assertThat(underlineSpan instanceof UnderlineSpan).isTrue();
  assertThat(strikeThroughSpan instanceof StrikethroughSpan).isTrue();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:17,代码来源:ReactTextTest.java

示例9: onUpdateView

import android.text.style.StrikethroughSpan; //导入依赖的package包/类
@SuppressLint("SetTextI18n") /* This will only display US prices */
@Override
public void onUpdateView(JSONObject result) {
    try {
        double salePrice = result.getDouble("salePrice");
        double promoPrice = result.getDouble("promoPrice");
        double lowestPrice = Math.min(salePrice, promoPrice);

        final String priceText = SYMBOL_MONEY + lowestPrice;
        final SpannableStringBuilder finalText = new SpannableStringBuilder(priceText);

        finalText.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.colorPrice)), 0, priceText.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
        finalText.setSpan(new StyleSpan(Typeface.BOLD), 0, priceText.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);

        if (salePrice != promoPrice) {
            finalText.append(" ").append(SYMBOL_MONEY).append(Double.toString(salePrice));
            finalText.setSpan(new StrikethroughSpan(), priceText.length() + 1, finalText.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
        }
        setText(finalText, BufferType.SPANNABLE);
    } catch (JSONException e) {
        Toast.makeText(context, "Error parsing result:" + e.getMessage(), Toast.LENGTH_SHORT).show();
    }
}
 
开发者ID:algolia,项目名称:instantsearch-android-examples,代码行数:24,代码来源:PriceView.java

示例10: TextReshow

import android.text.style.StrikethroughSpan; //导入依赖的package包/类
private void TextReshow(int index, App utils, ViewHolder view, boolean show, String listtext) {
    FloatTextUtils textutils = utils.getTextutil();
    if (!show) {
        SpannableString str = new SpannableString(listtext);
        str.setSpan(new StrikethroughSpan(), 0, str.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        view.textView.setText(str);
    } else {
        view.textView.setText(listtext);
    }
    if (typeface != null) {
        view.textView.setTypeface(typeface);
    }
    if (textutils.getTextShadow().get(index)) {
        view.textView.setShadowLayer(textutils.getTextShadowRadius().get(index), textutils.getTextShadowX().get(index), textutils.getTextShadowY().get(index), textutils.getTextShadowColor().get(index));
    } else {
        view.textView.setShadowLayer(0, 0, 0, 0);
    }
    view.textView.getPaint().setFakeBoldText(utils.getTextutil().getThickShow().get(index));
    view.textView.setTextColor(utils.getTextutil().getColorShow().get(index));
    view.textView.setEllipsize(TextUtils.TruncateAt.END);
}
 
开发者ID:XFY9326,项目名称:FloatText,代码行数:22,代码来源:ListViewAdapter.java

示例11: endCssStyle

import android.text.style.StrikethroughSpan; //导入依赖的package包/类
private static void endCssStyle(Editable text) {
    Font font = getLast(text, Font.class);
    if (font != null) {
        if (font.mFace.equalsIgnoreCase("fontello")) {
            setSpanFromMark(text, font, new AssetsTypefaceSpan(App.getContext(), "fontello/fontello.ttf"));
        }
    }
    Strikethrough s = getLast(text, Strikethrough.class);
    if (s != null) {
        setSpanFromMark(text, s, new StrikethroughSpan());
    }
    Background b = getLast(text, Background.class);
    if (b != null) {
        setSpanFromMark(text, b, new BackgroundColorSpan(b.mBackgroundColor));
    }
    Foreground f = getLast(text, Foreground.class);
    if (f != null) {
        setSpanFromMark(text, f, new ForegroundColorSpan(f.mForegroundColor));
    }

}
 
开发者ID:RadiationX,项目名称:ForPDA,代码行数:22,代码来源:Html.java

示例12: addOrRemoveStrikeTextView

import android.text.style.StrikethroughSpan; //导入依赖的package包/类
/**
 * Method that adds or removes a strike from a TextView object
 *
 * @param textView The textView to manage
 */
private final void addOrRemoveStrikeTextView(TextView textView, boolean toAdd)
{
  textView.setText(textView.getText().toString(), TextView.BufferType.SPANNABLE);
  final Spannable spannable = (Spannable) textView.getText();

  if (toAdd == true)
  {
    // Add a StrikethroughSpan style
    final StrikethroughSpan strikethroughSpan = new StrikethroughSpan();
    spannable.setSpan(strikethroughSpan, 0, textView.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
  }
  else
  {
    // Remove only StrikethroughSpan style
    final Object spans[] = spannable.getSpans(0, textView.length(), Object.class);
    for (final Object span : spans)
    {
      if (span instanceof StrikethroughSpan == true)
      {
        spannable.removeSpan(span);
        return;
      }
    }
  }
}
 
开发者ID:Azure,项目名称:azure-mobile-engagement-app-android,代码行数:31,代码来源:ProductDiscountActivity.java

示例13: handleEndTag

import android.text.style.StrikethroughSpan; //导入依赖的package包/类
private void handleEndTag(CharacterStyle style) {
    if (style instanceof URLSpan) {
        mOut.append("</a>");
    } else if (style instanceof TypefaceSpan) {
        mOut.append("</font>");
    } else if (style instanceof ForegroundColorSpan) {
        mOut.append("</font>");
    } else if (style instanceof BackgroundColorSpan) {
        mOut.append("</font>");
    } else if (style instanceof AbsoluteSizeSpan) {
        mOut.append("</font>");
    } else if (style instanceof StrikethroughSpan) {
        mOut.append("</strike>");
    } else if (style instanceof SubscriptSpan) {
        mOut.append("</sub>");
    } else if (style instanceof SuperscriptSpan) {
        mOut.append("</sup>");
    } else if (style instanceof UnderlineSpan) {
        mOut.append("</u>");
    } else if (style instanceof BoldSpan) {
        mOut.append("</b>");
    } else if (style instanceof ItalicSpan) {
        mOut.append("</i>");
    }
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:26,代码来源:ConverterSpannedToHtml.java

示例14: strikethroughInvalid

import android.text.style.StrikethroughSpan; //导入依赖的package包/类
private void strikethroughInvalid(int start, int end) {
    if (start >= end) {
        return;
    }

    StrikethroughSpan[] spans = getEditableText().getSpans(start, end, StrikethroughSpan.class);
    List<KnifePart> list = new ArrayList<>();

    for (StrikethroughSpan span : spans) {
        list.add(new KnifePart(getEditableText().getSpanStart(span), getEditableText().getSpanEnd(span)));
        getEditableText().removeSpan(span);
    }

    for (KnifePart part : list) {
        if (part.isValid()) {
            if (part.getStart() < start) {
                strikethroughValid(part.getStart(), start);
            }

            if (part.getEnd() > end) {
                strikethroughValid(end, part.getEnd());
            }
        }
    }
}
 
开发者ID:mthli,项目名称:Type,代码行数:26,代码来源:KnifeText.java

示例15: containStrikethrough

import android.text.style.StrikethroughSpan; //导入依赖的package包/类
private boolean containStrikethrough(int start, int end) {
    if (start > end) {
        return false;
    }

    if (start == end) {
        if (start - 1 < 0 || start + 1 > getEditableText().length()) {
            return false;
        } else {
            StrikethroughSpan[] before = getEditableText().getSpans(start - 1, start, StrikethroughSpan.class);
            StrikethroughSpan[] after = getEditableText().getSpans(start, start + 1, StrikethroughSpan.class);
            return before.length > 0 && after.length > 0;
        }
    } else {
        StringBuilder builder = new StringBuilder();

        for (int i = start; i < end; i++) {
            if (getEditableText().getSpans(i, i + 1, StrikethroughSpan.class).length > 0) {
                builder.append(getEditableText().subSequence(i, i + 1).toString());
            }
        }

        return getEditableText().subSequence(start, end).toString().equals(builder.toString());
    }
}
 
开发者ID:mthli,项目名称:Type,代码行数:26,代码来源:KnifeText.java


注:本文中的android.text.style.StrikethroughSpan类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。