gpt4 book ai didi

java - 在android中缩进TextView文本

转载 作者:搜寻专家 更新时间:2023-11-01 08:04:27 26 4
gpt4 key购买 nike

我有一个 textView 文本让我们说

• I am asking a question from
stackoverflow

如何让我的 textView 显示它

• I am asking a question from
stackoverflow




String facil = accomodation.facilities;
facil = facil.replace("<>", "%");
Spanned sp = Html.fromHtml(facil);
facil = sp.toString();

String[] items = facil.split("%");
CharSequence allFacil = "";

for (int i = 0; i < items.length; i++)
{
String text = items[i];
SpannableString s = new SpannableString("• " + text + "\n");
s.setSpan(new BulletSpan(BulletSpan.STANDARD_GAP_WIDTH), 0, text.length(), 0);
allFacil = TextUtils.concat(allFacil, s);
}

facilities.setText(allFacil.toString());

最佳答案

我是这样做的...

String[] items = new String[] { "item 1", "item 2", "item 3" };
CharSequence allText = "";
for (int i = 0; i < items.length; i++)
{
String text = items[i];
SpannableString s = new SpannableString(text + "\n");
s.setSpan(new BulletSpan(BulletSpan.STANDARD_GAP_WIDTH), 0, text.length(), 0);
allText = TextUtils.concat(allText, s);
}

...

public class BulletSpan implements LeadingMarginSpan...

关于java - 在android中缩进TextView文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16443073/

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