0

I want the image path from the drawable under resources as a string but it shows error . But I can't identify what the error is. I provide some code snippet.

listView = view.findViewById(R.id.listView); ArrayList<Card> list = new ArrayList<>(); //here the error String img = "drawable://" + R.drawable.tiger; 

Note: when I placed image name (tiger) it gives me error

list.add(new Card("drawable://" + R.drawable.tiger, "Royal Bengal Tiger")); 
3
  • why do you use "drawable://"? Do you want to access the drawable using name string? Commented Jan 16, 2019 at 19:26
  • it is followed by a tutorial.Check this : github.com/mitchtabian/AppBarLayouts/blob/master/… Commented Jan 16, 2019 at 19:31
  • 1
    Do you use exactly these classes? I mean ImageLoader for example. Commented Jan 16, 2019 at 19:35

2 Answers 2

1

i want the image path from the drawable under resources

A drawable resource is a file on your development machine. It is not a file on the device. There is no path to it on the device.

i provide some code snippet

There is no drawable scheme in Android. This also is not an image path.

If your Card requires a Uri, you can try android.resource as a scheme.

Sign up to request clarification or add additional context in comments.

2 Comments

You would need to talk to the developer of that tutorial. We cannot help you with that tutorial, as we did not write it.
1

That's not how you get resources

what you want is ContextCompat.getDrawable(context, R.drawable.name);

2 Comments

That example uses a library called Universal Image Loader without going through that library and seeing what is does with that string I cant tell you but its not behavior that you can get without it

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.