Micro-Credit Public account development tutorial (vii) Use of newline characters in text messages

Source: Internet
Author: User
Tags expression stringbuffer

This article mainly describes the benefits of using line breaks in text messages and how to use line breaks.

Although I have not had time to write a blog in the last one months, I have been seriously answering the questions raised by you. Received so many responses, concerns and thank you, or quite a sense of achievement, let me feel that this matter more and more meaningful, more determined I continue to write down the determination. After the previous six articles of the explanation, I believe in reading the article you, have mastered the basic development knowledge of micro-credit public accounts (based on Java), such as frame building, API encapsulation, message receiving and reply, etc. the next series of articles will focus on the development of public account development skills and practical features (such as weather query, Peripheral search, man-machine conversation, etc.).

Benefits of using line wrapping and examples

The advantage of using line wrapping is to make the presentation of information more neat, beautiful and intuitive, appropriate in the text message to use line breaks, people will be able to see after the feeling is very comfortable, clear and clear. The following is a sample of the main menu of the public account Xiaoqrobot, which is reasonable to use the line break character, look is not very intuitive, refreshing it? What Think it's ugly? Well, that's my narcissism ... )

You can imagine if this text menu doesn't use a newline character, what would it look like?

How do I use line breaks in text messages?

In the text message of the micro-credit public account, the line break is still "\ n", the following is the code to explain how the Xiaoqrobot text menu is implemented?

 * Xiaoqrobot main Menu 
 * @return 
static String Getmainmenu () {  
    StringBuffer buffer = New StringBuffer ();  
    Buffer.append ("Hello, I am little Q, please reply to the number selection service:"). Append ("\ n \ nthe");  
    Buffer.append ("1  Weather Forecast"). Append ("\ n");  
    Buffer.append ("2  Bus Enquiry"). Append ("\ n");  
    Buffer.append ("3  Peripheral Search"). Append ("\ n");  
    Buffer.append ("4  songs On Demand"). Append ("\ n");  
    Buffer.append ("5  Classic Game"). Append ("\ n");  
    Buffer.append ("6  Belle Radio"). Append ("\ n");  
    Buffer.append ("7  Face Recognition"). Append ("\ n");  
    Buffer.append ("8  chat chit chat when"). Append ("\ n \ nthe");  
    Buffer.append ("Reply"?) Show this Help menu ");  
    return buffer.tostring ();  

How about, realize is not very simple?

1) 9-16 lines is the menu item, and each menu item is separated by a newline character;

2 line 8th, the end of the 16th are used two line break, so you can separate the menu items and other content, more layered sense, it will look comfortable, intuitive point.

Perhaps attentive friends have found out: in the screenshot, "Peripheral search" and "Beauty radio" behind all have a "gift" expression, and the code did not see, this is I specifically removed, because I intend to use an article behind the QQ expression of the sending, processing, receiving speak clearly.

Details determine success or failure!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.