删除线不会保存到 SQLite 数据库
Strike through text is not saved to SQLite database
我遇到了一个问题,当使用 StrikethroughSpan 时,删除线文本没有保存到我的应用程序的 SQLite 数据库中。它与其他跨度一起工作,特别是与 StyleSpan 和 UnderlineSpan - bold/italic/underlined 文本正确保存到数据库并由 CursorAdapter 显示。为此,我正在使用 HtmlCompat。但是删除线显示为纯文本,没有格式。
我对此事的网络研究没有给出任何结果。这种行为的原因是什么,有没有办法解决这个问题?
我将跨区文本保存到数据库的代码:
ContentValues values = new ContentValues();
NoteCursorAdapter cursorAdapter = new NoteCursorAdapter(this, null);
String newHtmlString = HtmlCompat.toHtml(noteText, TO_HTML_PARAGRAPH_LINES_CONSECUTIVE);
values.put(NoteEntry.COLUMN_NOTE_TEXT, newHtmlString);
在activity中:
@Override
public void bindView(View view, Context context, Cursor cursor) {
...
String htmlFormString = cursor.getString(noteBitmapColumnIndex);
Spanned spannedText = HtmlCompat.fromHtml(htmlFormString, FROM_HTML_SEPARATOR_LINE_BREAK_BLOCKQUOTE);
noteBitmap.setText(spannedText);
}
在 CursorAdapter 中:
@Override
public void onLoadFinished(...) {
...
htmlString = cursor.getString(textColumnIndex);
realText = HtmlCompat.fromHtml(htmlFormString, FROM_HTML_SEPARATOR_LINE_BREAK_BLOCKQUOTE);
mNoteText.setText(realText);
ContentValues(newHtmlString)中的html字符串显示对应的HTML标签:
I/System.out: <p dir="ltr"><b><b><strike>Word</strike></b></b></p>
但是没有显示格式。
我遇到了一个问题,当使用 StrikethroughSpan 时,删除线文本没有保存到我的应用程序的 SQLite 数据库中。它与其他跨度一起工作,特别是与 StyleSpan 和 UnderlineSpan - bold/italic/underlined 文本正确保存到数据库并由 CursorAdapter 显示。为此,我正在使用 HtmlCompat。但是删除线显示为纯文本,没有格式。
我对此事的网络研究没有给出任何结果。这种行为的原因是什么,有没有办法解决这个问题?
我将跨区文本保存到数据库的代码:
ContentValues values = new ContentValues();
NoteCursorAdapter cursorAdapter = new NoteCursorAdapter(this, null);
String newHtmlString = HtmlCompat.toHtml(noteText, TO_HTML_PARAGRAPH_LINES_CONSECUTIVE);
values.put(NoteEntry.COLUMN_NOTE_TEXT, newHtmlString);
在activity中:
@Override
public void bindView(View view, Context context, Cursor cursor) {
...
String htmlFormString = cursor.getString(noteBitmapColumnIndex);
Spanned spannedText = HtmlCompat.fromHtml(htmlFormString, FROM_HTML_SEPARATOR_LINE_BREAK_BLOCKQUOTE);
noteBitmap.setText(spannedText);
}
在 CursorAdapter 中:
@Override
public void onLoadFinished(...) {
...
htmlString = cursor.getString(textColumnIndex);
realText = HtmlCompat.fromHtml(htmlFormString, FROM_HTML_SEPARATOR_LINE_BREAK_BLOCKQUOTE);
mNoteText.setText(realText);
ContentValues(newHtmlString)中的html字符串显示对应的HTML标签:
I/System.out: <p dir="ltr"><b><b><strike>Word</strike></b></b></p>
但是没有显示格式。