Skip to content

(android)about format string  #3

@IamANYWHERE

Description

@IamANYWHERE

when I learned the book named android编程权威指南 I encountered a problem.It is print out a format string.So I find some answer.
If I want to show a string dynamically,I can use %1$s etc.
Here are the formats.

%n$ms: n represent the n th variate,m represent leave m spaces,s represent the variate is string.
%n$md: n represent the n th variate,m represent leave m spaces,s represent the variate is integer.
%n$mf: n represent the n th variate,m represent leave m spaces,s represent the variate is float.
It can also be expressed by %d %f %s

String string=getResources().getString(R,string.---);
String formated=string.format(string, Object... args);

String formated=getString(R,string.---,Object... args);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions