The platform already does this for you -- just retrieve the Drawable through
the Resources object.

On Sat, Jul 10, 2010 at 6:32 AM, Gyscos <[email protected]> wrote:

> Hi people !
>
> I'm trying to use 9-patches in my application.
>
> At first, I created one NinePatchDrawable that I used in every Button,
> but this lead to some problems :
> http://pastebin.com/pBep1NM0
>
> This happened with any Drawable, including NinePatchDrawable or
> BitmapDrawable.
>
> Someone told me that it was because Drawable was storing some shared
> values, so I decided to use one Drawable per button...
>
> But since I was going to use many NinePatchDrawable with the same
> NinePatch, I thought it might be a better idea to first create a
> NinePatch, and then distribute NinePatchDrawable based on this
> NinePatch.
>
> But the NinePatchDrawable(Resouce, NinePatch) constructor produces a
> null-pointer exception because no padding is entered... (By the way,
> why is this constructor public then ?... Since it directly calls
> setNinePatchState, wich calls computeBitmapSize, where the error
> occurs...).
>
> So what's the way to do it ? Directly call
> Resource.getDrawable() ?... :-/ But then it gets more difficult to
> control when the data is loaded... (When calling multiple times
> Resource.getDrawable() with the same file, only the first call loads
> the file, right ? The others are faster ?)
>
> What is the clean way to use Managers to handle this ?...
>
> Thanks  :)
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to