<?xml version="1.0" encoding="utf-8"?>
<resources>
<plurals name="message">
<item quantity="one">You have one new message</item>
<item quantity="other">You have %d new messages</item>
</plurals>
</resources>
'JAVA
#if Java
public int getResourceId(String type, String name)
{
return BA.applicationContext.getResources().getIdentifier(name, type, BA.packageName);
}
public String FormatPlural(int id, int count) {
return BA.applicationContext.getResources().getQuantityString(id, count, count);
}
#End If
'B4A
Sub Activity_Create(FirstTime As Boolean)
Private NativeMe As JavaObject
NativeMe.InitializeContext
Dim id As Int = NativeMe.RunMethod("getResourceId", Array("plurals","message"))
Dim s As String = NativeMe.RunMethod("FormatPlural", Array(id,1))
Log(s)
Dim s As String = NativeMe.RunMethod("FormatPlural", Array(id,2))
Log(s)
End Sub
'RESULTS
'You have one new message
'You have 2 new messages