gpt4 book ai didi

android - 在 firebase 数据库中,我可以存储项目符号、其他符号吗?如果是,如何?

转载 作者:行者123 更新时间:2023-11-29 23:45:40 25 4
gpt4 key购买 nike

在我的应用程序中,我想将博文保存在 firebase 实时数据库中,并希望使用这样的符号上传我的博文

enter image description here

有什么办法吗?我没找到。我的代码

mPost.setText(fromHtml(dataSnapshot.child("post").getValue().toString()));

@SuppressWarnings("deprecation")
public static Spanned fromHtml(String html){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY);
} else {
return Html.fromHtml(html);
}
}

<ul><li>Item 1</li><br><li>Item 2</li></ul>

输出:
项目1
项目 2

最佳答案

您可以使用 html 字符串上传它。

例如,如果你想上传一个无序列表:

Upload following string in firebase db
"stringVal" : "<b>Title</b><br><br>&#8226; item1<br>&#8226;item2<br>&#8226;item3"

然后像这样在 android(使用 java)中显示它:

TextView foo = (TextView)findViewById(R.id.foo);
foo.setText(Html.fromHtml(<String from firebase db>));

输出:

标题

  • 项目 1
  • 项目 2
  • 第 3 项

引用:link

关于android - 在 firebase 数据库中,我可以存储项目符号、其他符号吗?如果是,如何?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51462869/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com