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
  • 813
  • 13
  • 24

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
  • 29,432
  • 22
  • 140
  • 255