• Advertisement
Sign in to follow this  

Adding 9-patch resource android

This topic is 1243 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to add a 9-patch image for a button.
 
Its supposed to be in the /res/drawable/ but I need an identifier in R.java. How do I do that?
 
I copied the .9.png image to all the res/drawable-*/. But I don't know how to get an $res. identifier.

Share this post


Link to post
Share on other sites
Advertisement
So I'm not sure I follow.

You have a resource stored in your jar file. You also write you "need an identifier", which seems confusing. Normally you don't need an identifier, you need a stream for the resource.

The normal way of doing it is something like: InputStream is = getClass().getResourceAsStream("/res/caseSensitiveFileName.png");

That will allow you to stream whatever resource you need out of your file (recalling that jar files are nothing more than standard zip files which use a per-file stream-based encoding). Also remember that even if your system uses NTFS or FAT or another non-case-sensitive file system, the file table in zip is (and always has been) case sensitive.

Share this post


Link to post
Share on other sites

It says I need to set the background using 

 
        android:background="@drawable/my_button_background"
 
But I don't know how to set a string in the string table to point to one of the /res/drawable/ resources.

Share this post


Link to post
Share on other sites

Those identifiers should be automatically generated for you, so you should not need to add it anywhere, they should "just work".

 

Maybe your IDE needs to be refreshed or the project cleaned at rebuilt.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement