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