如果我使用字符串文件中的html链接保留文本并使用:
,那么一切都很顺利View view = View.inflate(mContext, R.layout.general_info, null);
TextView textView = (TextView) view.findViewById(R.id.message);
textView.setMovementMethod(LinkMovementMethod.getInstance());
textView.setText(R.string.general_info_message);
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setTitle(
"General Information").setView(view)
.setPositiveButton(android.R.string.ok, null)
.setIcon(R.drawable.icon);
alert = builder.create();
但如果我改变
textView.setText(R.string.general_info_message);
到
InputStream is = getResources().openRawResource(R.raw.general_info);
String general_info_message = new Scanner(is).useDelimiter("\\A").next();
final SpannableString s =
new SpannableString(general_info_message);
...
textView.setText(s);
并将.txt文件中的文本保存在res / raw中,只显示带有所有html标签的文本,但不要解释它们