Reputation: 903
I have a resource manager with the following method
fun getString(@StringRes resId: Int, vararg params: Any): String {
return context.getString(resId, params)
}
I call it like this
resourceManager.getString(R.string.number_reps, "20")
Here is the string:
<string name="number_reps">%1$s reps</string>
For some reason when i call this method it returns this really weird string:
[Ljava.lang.Object;@5356cf reps
Does anyone know why this would happen
UPDATE
This worked for me
String.format(resourceManager.getString(R.string.number_reps), "20")
Upvotes: 0
Views: 99
Reputation: 7285
You are using a wrong key while accessing the string.
Use this resourceManager.getString(R.string.number_reps, "20")
You can also use String.format
to achieve the same results like below,
String.format(getString(R.string.number_reps), "20")
Upvotes: 0
Reputation: 837
try to replace
resourceManager.getString(R.string.number_repetitions, "20")
by
resourceManager.getString(R.string.number_reps, "20")
Upvotes: 1