From 71825f49d70d54b581ff2680971554974dd3ae99 Mon Sep 17 00:00:00 2001
From: Scott Main You can use either {@link android.content.Context#getString(int)} or
-{@link android.content.Context#getText(int)} to retieve a string. {@link
+{@link android.content.Context#getText(int)} to retrieve a string. {@link
android.content.Context#getText(int)} will retain any rich text styling applied to the string. Note that the selection is made based on grammatical necessity. A string for When using the {@link android.content.res.Resources#getQuantityString(int,int,int)
+getQuantityString()} method, you need to pass the {@code count} twice if your string includes
+string formatting with a number. For example, for the string
+{@code %d songs found}, the first {@count} parameter selects the appropriate plural string and the
+second {@count} parameter is inserted into the {@code %d} placeholder. If your plural strings do not
+include string formatting, you don't need to pass the third parameter to {@link
+android.content.res.Resources#getQuantityString(int,int)
+getQuantityString}. In this example, the format string has two arguments: {@code %1$s} is a string and {@code %2$d}
-is a decimal number. You can format the string with arguements from your application like this:zero
in English will be ignored even if the quantity is 0, because 0 isn't grammatically different
-from 2, or any other number except 1 ("zero books", "one book", "two books", et cetera).
+from 2, or any other number except 1 ("zero books", "one book", "two books", and so on).
Don't be misled either by the fact that, say, two
sounds like it could only apply to
-the quantity 2: a language may require that 2, 12, 102 (et cetera) are all treated like one
+the quantity 2: a language may require that 2, 12, 102 (and so on) are all treated like one
another but differently to other quantities. Rely on your translator to know what distinctions
their language actually insists upon.
@@ -358,9 +358,17 @@ values, with non-exhaustive examples in parentheses:
int count = getNumberOfsongsAvailable();
Resources res = {@link android.content.Context#getResources()};
-String songsFound = res.{@link android.content.res.Resources#getQuantityString(int,int)
-getQuantityString}(R.plurals.numberOfSongsAvailable, count);
+String songsFound = res.{@link android.content.res.Resources#getQuantityString(int,int,int)
+getQuantityString}(R.plurals.numberOfSongsAvailable, count, count);
+
Resources res = {@link android.content.Context#getResources()}; -- cgit v1.1