Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

android translate string java

Let's say you want to display this and also translate it:
Hello, [display name]! You have [display an other variable] new messages.

Put your string in the strings.xml file with this %n$s as fields:
<string name="welcome_messages">Hello, %1$s! You have %2$d new messages.</string>

Get and set in your class in this way:
Resources res = getResources(); //previously done
String text = String.format(res.getString(R.string.welcome_messages), username, mailCount);
Comment

PREVIOUS NEXT
Code Example
::  
Java :: groovy ternary operator short form 
:: android alertdialog setSingleChoiceItems 
:: android toast message 
Java ::  
Java ::  
Java ::  
::  
:: java foreach arraylist 
Java ::  
::  
::  
::  
Java ::  
::  
Java :: Exception in thread "main" java.util.zip.ZipException: error 
::  
:: start activity for result deprecated 
::  
::  
:: lambda comparator java 
::  
:: string.join java 8 
Java ::  
Java ::  
::  
:: milliseconds to seconds java 
Java ::  
Java :: fill two dimensional array row by row java 
Java ::  
ADD CONTENT
Topic
Content
Source link
Name
4+2 =