Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何将Html.fromHtml设置为SingleChoiceItems?_Android - Fatal编程技术网

Android 如何将Html.fromHtml设置为SingleChoiceItems?

Android 如何将Html.fromHtml设置为SingleChoiceItems?,android,Android,我正在尝试将Html标记应用于AlertDialog->setSingleChoiceItems() 我在寻找答案,但什么也没找到 我的示例代码 final String ex[] = { "<small>Some text</small>\n<b>text</b>", "<small>Some text</small>\n<b>text</b>", "<small>

我正在尝试将Html标记应用于AlertDialog->setSingleChoiceItems()

我在寻找答案,但什么也没找到

我的示例代码

final String ex[] = {
    "<small>Some text</small>\n<b>text</b>",
    "<small>Some text</small>\n<b>text</b>",
    "<small>Some text</small>\n<b>text</b>"
};

AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity());

dialog.setTitle("My dialog");
dialog.setIcon(R.drawable.icon);
dialog.setSingleChoiceItems(ex, 0, null);

dialog.show();
final String ex[]={
“一些文本\n文本”,
“一些文本\n文本”,
“一些文本\n文本”
};
AlertDialog.Builder dialog=新建AlertDialog.Builder(getActivity());
对话框.setTitle(“我的对话框”);
dialog.setIcon(R.drawable.icon);
setSingleChoiceItems(ex,0,null);
dialog.show();
如何应用html标记并在列表中显示它们

我尝试在字符串数组中使用Html.fromHtml,但它是不兼容的类型

有什么帮助吗?
谢谢。

设置SingleChoiceItems
接受一个
字符序列
数组,bot
字符串和
Spannable
从中继承。这应该可以

final CharSequence ex[] = {
       Html.fromHtml("<small>Some text</small>\n<b>text</b>"),
       Html.fromHtml("<small>Some text</small>\n<b>text</b>"),
       Html.fromHtml("<small>Some text</small>\n<b>text</b>")
};
final CharSequence ex[]={
Html.fromHtml(“某些文本\n文本”),
Html.fromHtml(“某些文本\n文本”),
Html.fromHtml(“某些文本\n文本”)
};

setSingleChoiceItems
接受一个
CharSequence
数组,bot
String
Spannable
从中继承。这应该可以

final CharSequence ex[] = {
       Html.fromHtml("<small>Some text</small>\n<b>text</b>"),
       Html.fromHtml("<small>Some text</small>\n<b>text</b>"),
       Html.fromHtml("<small>Some text</small>\n<b>text</b>")
};
final CharSequence ex[]={
Html.fromHtml(“某些文本\n文本”),
Html.fromHtml(“某些文本\n文本”),
Html.fromHtml(“某些文本\n文本”)
};