简体   繁体   中英

Escape newline character using textview in android studio

I am trying to display the line

printf("a*b : %.2f\n",a*b);

in android studio using textview. It is implementing \\n as new line instead of displaying it as text.

How can I escape the \\n so that it displays "\\n" as text?

您应该转义\\字符,尝试使用\\\\n而不是\\n

printf("ab : %.2f\\n",ab);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM