String android.content.Context.getString(int resId, Object... formatArgs)
public final String getString (int resId, Object... formatArgs)
Since: API Level 1
Return a localized formatted string from the application's package's default string table, substituting the format arguments as defined in Formatter and format(String, Object...).
Parameters
resId Resource id for the format string
formatArgs The format arguments that will be used for substitution.
举例如下:
XML文件定义,
<string name="imcoming_message_ticker_text">New text message: <xliff:g id="text">%0$s</xliff:g></string>
代码中如下定义,
CharSequence message = "kthx. meet u for dinner. cul8r";
String tickerText = getString(R.string.imcoming_message_ticker_text, message);
返回值tickerText将是如下格式,
New text message: kthx. meet u for dinner. cul8r