1
很簡單的問題:如何從TextView的樣式文本
我有一些TextView的
TextView textView = (TextView) findViewById(R.id.textView1);
我設置樣式的文本(與
<b>
標籤或任何其他標籤)textView.setText(Html.fromHtml("Simple text. <b>Bold text</b>. Simple text."));
問題:當我打電話給textView.getText()
我收到Simple text. Bold text. Simple text.
。某種程度上,<b>
標籤已經消失。
如何從TextView中檢索帶格式的文本?
你只是硬編碼字符串?爲什麼不把原始字符串保存在某個地方,比如static-final? – Karakuri
我的猜測是,你將不得不使用Html.toHtml()(http://developer.android.com/reference/android/text/Html.html#toHtml(android.text.Spanned))和TextView.getEditableText ()as Editable是從「Spanned」派生出來的,它是爲Html.toHtml輸入的。 http://developer.android.com/reference/android/text/Spanned.html –
@Karakuri有很多字符串,他們會在運行時更改。 – kolobok