gpt4 book ai didi

android - 如何使用 xmlparsing 在来自 xml 的 android 值中为段落和背景图像 webview 设置换行符

转载 作者:行者123 更新时间:2023-11-29 16:06:22 26 4
gpt4 key购买 nike

我想在来自 XML 的 android 端值的 Web View 中设置换行符。我在 XML 中使用 (/n) 标签,但它不被接受。我不知道如何在段落中换行,我也想设置来自 drawable 文件夹的 webview 图像中的背景图像...

    protected void onCreate(Bundle savedInstanceState) 
{
super.onCreate(savedInstanceState);
setContentView(R.layout.rsslistitemdesc);
Bundle b = getIntent().getExtras();
desc=(WebView) findViewById(R.id.description);
itemdesc=getIntent().getExtras().getString("desc");
String htmlText = "%s ";
String description = "<html><body>" + "<p align=\"justify\" >"+"<font color=\"black\"><br>"+ b.getString("desc")+ "<br/></p>" + "</body></html>";
desc.loadData(String.format(htmlText, description), "text/html", "utf-8");
desc.setBackgroundColor(0);
desc.setBackgroundResource(Color.TRANSPARENT);
}

example.xml
<item>
<title></title>
<desc>A summary of your objectives,educational qualification,experience,skills relevant to the field of work you are going to enter.Here you can detail down each.It highlights your accomplishments to show a potential employer that you are qualified for the work you want.Remember it is not a biography of everything you have done.Its core PURPOSE is to get you an interview.A resume can or should reflect more than just your education.As a fresher the experience lies in the projects,seminars,workshops etc. you pursue during your academics.Showcase your important details like extra – curricular,volunteer &amp; leadership experiences.Tailoring separate resumes to fit each career field in which you are job searching may be important.Some people create slightly different resumes tailored to each job opening.
</desc>
</item>

最佳答案

您可以使用 "<br>"标记来完成任务。请参见下面的示例,

 desc=(WebView) findViewById(R.id.description);
String webdata="<html><body><p>To break lines<br>in a text,<br>use the br element./p</body</html>"
desc.loadData(webdata, "text/html", "utf-8");

这将导致以下输出,

To break lines
in a text,
use the br element.

关于android - 如何使用 xmlparsing 在来自 xml 的 android 值中为段落和背景图像 webview 设置换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17939313/

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