Isn't grammatically different from 2, or any other number except 1 ("zero books", "one book", In English, a string for zero will be ignored even if the quantity is 0, because 0 The selection of which string to use is made solely based on grammatical necessity. It might seem convenient to use quantity strings instead of an if statement,īut it's important to note that some languages (such as Chinese) don't make these grammaticalĭistinctions at all, so you'll always get the other string. Implement something like Gmail's "Inbox" versus "Inbox (12)" when there are unread messages, forĮxample. It would be a mistake to use quantity strings to So Android provides you with methods such asĪlthough historically called "quantity strings" (and still called that in API), quantity The rules for deciding which case to use for a given language and quantity can be very complex, The full set supported by Android is zero, This distinction between singular and plural is very common, but other We write "1 book", but for any other quantity we'd In English,įor example, the quantity 1 is a special case. getStringArray(R.anets_array) ĭifferent languages have different rules for grammatical agreement with quantity. This application code retrieves a string array: example: XML file saved at res/values/strings.xml: Information about to properly style and format your strings. A string, which can include styling tags. Contains one or more elements.Īttributes: name String. compiled resource datatype: Resource pointer to an array of Strings. Such, you can combine string array resources with other simple resources in the one XML file, Using the value provided in the name attribute (not the name of the XML file). Note: A string array is a simple resource that is referenced String ArrayĪn array of strings that can be referenced from the application. getText(int) will retain any rich text styling applied to the string. String string = getString(R.string.hello) This application code retrieves a string: This layout XML applies a string to a View: For more information about how to properly style and format your strings see Formatting and Styling, below.Īttributes: name String. Beware that you must escape apostrophes and compiled resource datatype: Resource pointer to a String. So, you canĬombine string resources with other simple resources in the one XML file, Note: A string is a simple resource that is referenced StringĪ single string that can be referenced from the application or from other resource files (such Information about styling and formatting strings, see the section about Formatting and Styling. Quantity Strings (Plurals) XML resource that carries different strings for pluralization.Īll strings are capable of applying some styling markup and formatting arguments. String Array XML resource that provides an array of strings. Your application with strings: String XML resource that provides a single string. There are three types of resources that can provide With optional text styling and formatting. A string resource provides text strings for your application
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |