In-depth explanation of Android development FAQ

Source: Internet
Author: User

Android is very popular now. Its So-called openness and free open source have attracted a large number of mobile phone hardware manufacturers to enter the Android camp. Another reason for its popularity is its platform application development. As Google said, Android development is quick and easy to get started, which is much easier than development on other platforms. However, it is not as easy as you imagine to become a master or develop a quality program. The first reason is that the Android documentation is not perfect, and many Api documentation is underwritten. For parameter descriptions, descriptions of return values, and some precautions, what is even more unbearable is that many APIs do not have documentation. Another reason is that Android is not doing well in details. Google wants to quickly come up with things and seize the market as soon as possible, an operating system has been quickly developed, but many places are not perfect, and many details are not well done. If you use the Android system carefully, you will find that there are many bugs, some are big and small, but there are always problems. If you study the code, you will find that many things are not doing well.
But then again, what is perfect? As developers, we need to constantly learn, sum up experience, find hidden traps, and then avoid or solve them during the development process.
This article will record some issues that are frequently encountered during development:
1. How can I conveniently and quickly display "XX unread messages exist", where XX is the actual variable number?
To solve this problem, we first think of "yes" + number + "unread information". There is a second solution: "There are # unread messages". replaceAll ("#", number ).
However, we recommend that you do this on Android:
A. First, such a famous string in the string resource file:
Copy codeThe Code is as follows: <string name = "unread_notification"> <xliff: g id = "number"> % 1 $ d </xliff: g> unread Information </string>

B. Use it in this way.
Copy codeThe Code is as follows: Context. getString (R. string. unrread_notification, 20 );

In this way, Resources. getString () will be automatically replaced to get the desired effect. The final result is: "20 unread messages exist"

Related Article

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.