0

how to get String in non context class of android from @String ?

my class is an adapter class and i am not using any context object in it.

Manisha
  • 732
  • 12
  • 23

1 Answers1

2

You will have to pass a context in.

The way you get to the @String values is by using the method Context.getResources().

My suggestion would be to keep a private field that holds the context, and initialise it in your adapter's constructor.

Richard Le Mesurier
  • 28,920
  • 20
  • 132
  • 247