Creating a Drawable Reference From a Path String

All your problems with Audio, Video and Images.

Creating a Drawable Reference From a Path String

Postby forcery » Mon Jun 15, 2009 7:29 pm

I'm trying to use [font=Courier New]Drawable.createFromPath(String path)[/font] to create a [font=Courier New]Drawable[/font] object to basically wrap an image I have so I can pass it to other methods. Let's call the image [font=Courier New]foo.png[/font], and yes it is in [font=Courier New]res/drawable[/font]. My question then is if this is the setup, exactly what string ought I to pass to [font=Courier New]Drawable.createFromPath[/font] to reference [font=Courier New]foo.png[/font]? This may seem like a trivial question, but I've tried a multitude of intuitive ways of describing the file with a string, and [font=Courier New]createFromPath[/font] just keeps on returning [font=Courier New]null[/font], which is of no use. I haven't been able to find much documentation for this method, so any help anyone can offer would be greatly appreciated.
forcery
Freshman
Freshman
 
Posts: 3
Joined: Mon Jun 15, 2009 7:08 pm
Location: Boston, MA

Top

Alternate Solution

Postby forcery » Tue Jun 16, 2009 9:24 pm

Well, I didn't figure out the problem I posted, but I did find a workaround. I was basically trying to get a Drawable from a String, and I found the solution elsewhere on this forum. See: viewtopic.php?p=17846 for anyone who runs into similar problems.
forcery
Freshman
Freshman
 
Posts: 3
Joined: Mon Jun 15, 2009 7:08 pm
Location: Boston, MA

Postby nmc » Tue Jun 16, 2009 11:56 pm

Hm, how about
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. BitmapFactory.decodeResource(context.getResources(), R.drawable.foo);
  3.  
  4.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
nmc
Senior Developer
Senior Developer
 
Posts: 154
Joined: Thu Nov 27, 2008 8:30 pm
Location: Germany

Postby lapusan » Sat Jul 11, 2009 11:50 am

try
Drawable d = getResources().getDrawable(R.drawable.imageId)
lapusan
Once Poster
Once Poster
 
Posts: 1
Joined: Sat Jul 11, 2009 11:45 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 11 guests