0

How to convert a string like "R.drawable.online" into a path, which can represent an image? What should I do for this?

Kara
  • 6,115
  • 16
  • 50
  • 57
Eric
  • 11
  • 2

2 Answers2

0

Take a look at this answer:

Android and getting a view with id cast as a string

By the way... that kind of resources cannot be access using a path... you must use the integer representation of it.

Community
  • 1
  • 1
Cristian
  • 198,401
  • 62
  • 356
  • 264
0

if you have an image inside your folder /drawable/online.png you will load your image for example into a ImageView...

ImageView.setImageDrawable(getResources().getDrawable(R.drawable.online));

Jorgesys
  • 124,308
  • 23
  • 334
  • 268