How do I call getString() inside the onBindViewHolder() method of a recycler view?
How do I use getString() inside the onBindViewHolder() method?
Every ViewHolder
instance has an itemView
field, which is an instance of View
. Every View
instance has a getContext()
method; you can use this to access resources.
String text = viewHolder.itemView.getContext().getString(R.string.mystring);
You can you get string resource using context.
context.getString(R.string.temperature)