Top stuff Kostya/Dianne. Thank you for the feedback.
I think before I look into anything else, I should do this first to
get
rid of the thousands of micro-allocations that take place there.

UI elements are drawn about 20 times per second and although I cache
values that don't change, a lot of the values do change quite
frequently.

I'll report back if I'm still having issues after I do this.

Thanx again,
kk.

On Nov 15, 7:31 pm, Kostya Vasilyev <kmans...@gmail.com> wrote:
> What I was suggesting was, rather than using Integer.toString(), or any
> other String / StringBulider methods, format the value yourself.
>
> In class declaration:
>
> char[] mMyHealthStr = new char[8];
> int mMyHealthLen = 0;
>
> When drawing:
>
> // convert integer to string in mMyHealthStr, set mMyHealthLen
>
> canvas.draw(mMyHealthStr, 0, mMyHealthLen, ..... blah blah .....);
>
> -- Kostya
>
> 15.11.2010 21:48, Dianne Hackborn ?????:
>
>
>
>
>
>
>
>
>
> > On Mon, Nov 15, 2010 at 8:37 AM, kk <kkostia...@gmail.com
> > <mailto:kkostia...@gmail.com>> wrote:
>
> >     private StringBuilder m_healthString = new StringBuilder(8);
> >      I update by doing:
> >     m_healthString.replace(0, 8, Integer.toString(myHealth));
> >     Is this expensive/wrong? Is there a better way to update a
> >     StringBuilder with a new String?
>
> > You haven't gained anything here, because Integer.toString() has
> > already had to make a string for that integer before you even get in
> > to the StringBuilder.
>
> > --
> > Dianne Hackborn
> > Android framework engineer
> > hack...@android.com <mailto:hack...@android.com>
>
> > 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 android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
> --
> Kostya Vasilyev -- WiFi Manager + pretty widget 
> --http://kmansoft.wordpress.com

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

Reply via email to