05-11-2013 09:47 AM
I have a labelfield with text.I want that when i click a button,the labelfield text should change.I have tried with labelfield.settext method,but its not working,plz help
Solved! Go to Solution.
05-11-2013 10:06 AM
<LabelField>.setText method does change the text. Debug the statement, I suspect it is throwing an Exception, probably because you are not invoking it on the Event Thread. .
05-11-2013 10:30 AM
if your LabelField is called lab and is on the screen, then
will update the display with "New Text", assuming you run this on the Event Thread.
05-12-2013 02:05 AM
yes true,but if i use draw text in paint method and than use settext in the onnavigation click of button field,text is overlapping on the old text,how to delete the old text
05-12-2013 05:40 AM
Ah - I thought you were using a standard LabelField. Might have been useful to mention that at the start.
If you really have to use drawText, then you should clear the area first. There are a variety of ways you can do that, but probably the easiest is to just call paintBackground in your paint() method.
Otherwise you can set the color and use fillRect. Review the Graphics API for more on these methods.
05-12-2013 05:43 AM
yes Peter i too hate using DrawText,but i dont have any option.Actually i need to position the text inside labelfield depending on alignment attribute value i am getting from an XMl,so suppose its CENTER,i am setting it at center in drawtext,anyways i will give ur solution a try and get back to u