本文整理匯總了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;
}
示例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
}
}
}
示例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);
}
}
}
示例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()));
}
}
示例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;
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
}
示例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);
}
示例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));
}
}
示例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;
}
}
}
}
示例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>");
}
}
示例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());
}
}
}
}
示例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());
}
}