# Loading skins in bananas 1.3?



## mondelicious (Jul 26, 2005)

Has anyone had any luck deciphering the documentation into real code?

I have been trying to load alternate images for the Bananas ui elements using each of the methods in the documentation (dir,zip,resource) to no avail.

Trying to run in the simulator reveals that it is not even looking in the dir that I try to specify. It is looking in com/tivo/hme/bananas/ and then getting a file not found exception.

I do not need a factory, like in the samples, i just need to load a few elements once.

Any advice? links to better explained resources?

Thanks.
Edmond


----------



## F8ster (May 26, 2002)

Not sure whether you're talking about skins or other resources, so I'll cover them both.

*Skins*

I'm using them successfully in the new Stock Viewer app. Here's the relevant code snippet:


```
public static final String SKIN_FILENAME = "images" + File.separator + "skin-charcoal.zip";
...
setSkin(new BZipSkin(this, SKIN_FILENAME));
```
I took all of the files in the Bananas toolkit under samples\skin-charcoal and created a file called "skin-charcoal.zip". I placed it in the root of my application directory under images\skin-charcoal.zip and everything works peachy.

You should be able to replace each of the individual files (the .png files) with your own graphics, keeping the same name.

*Other Resources*

This is one other trick I've learned: to avoid path problems with creating resources out of images, put them in your source package. For example, my root package is com.bitrazor.stock, so I put any images I want to create resources out of into com\bitrazor\stock. The easiest way to do this is just to drag and drop them on your package in Eclipse or NetBeans and it'll put them in the right place.

I prefer this method because then you don't have to worry about the images being in a different location during development vs. release, etc. For example, here's a code snippet that shows creating a resource out of an image:


```
public static final String tickerRowIcon = "yellow14.png";
BView icon = new BView(theParent, 10, 7, 14, 14, false);
icon.setResource(tickerRowIcon);
```
Notice that "yellow14.png" is in the packge -- here's the screenshot from NetBeans:










Hope this helps -- Dave


----------



## mondelicious (Jul 26, 2005)

Thanks, again, Dave.

I went with the BResSkin method, riffing off your "in the package" advice. So I have a folder in my package with Skin Dirs inside. But, using :

setSkin(new BResSkin(this,"com/edmondcho/tivoslimserverclient/skins/gray-flat/"));

I was able to load up my skin images!

Plus the bonus is that I can work in a similar way to the BDirSkin method, I just have to drag my images to the folder in Eclipse. Not quite as simple as just saving in a directory, but easier than zipping up a new skin.

Cheers,
Edmond

p.s. I will be dropping my Tivo HME app on the public any day now!


----------

