我在我的 Android 应用程序的 edittext 字段中添加了粗体文本。如果插入的粗体文本是两个或多个单词,例如“words words”,它将在 HTML 中标记为“<\b>words words</b>”。但是,如果我退格说单词中的 s,则标记将更改为“<\b>words</b>\word</b>”。有人知道这是为什么吗?谢谢
(我在粗体标签中添加正斜杠以显示标签,而不是堆栈溢出将它们更改为粗体文本)
编辑:
这是将粗体文本添加到编辑文本框的代码。
// Set up the buttons
builder.setPositiveButton("Add Field",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
field[y] = input.getText().toString();
moreText = "<b>" + field[y] + "</b>";
Log.d("ADebugTagMoreText", "Value: " + moreText);
Text = story.getText();
Text = Text.replace(start, end, Html.fromHtml(moreText));
Log.d("ADebugTagText", "Value: " + Text);
storyText = Text;
story.setText(storyText);