现在我正在编写简单的笔记应用程序。我需要在 EditText 中显示格式化的单独选定文本。
I tried,
EditText et = (EditText)findViewById(R.id.edittext);
String string;
int startSelection = et.getSelectionStart();
int endSelection = et.getSelectionEnd();
string = et.getText().toString();
string.substring(startSelection, endSelection);
Spanned s = Html.fromHtml("<font color=\"red\">" + string + "</font>");
et.setText(s);
此解决方案仅显示单独的选定文本。但我需要在其他文本中显示格式化文本。我不知道。
UPD:当用户单击按钮时发生格式化。
Try this
EditText text = new EditText(this);
text.setText(Html.fromHtml(html));
text.setMovementMethod(LinkMovementMethod.getInstance());
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)