Android Java: .setText() every x ms -
i want following: give string global function in app , function opens framelayout looks speech bubble. 1 includes textview string. works pretty far - want "live speech". text shouldn't appear, every single character after x miliseconds. like:
h
he
hel
hell
(etc.)
do have ideas that? thanks!
i've written class extending asynctask
quick example of how can this:
public class typertask extends asynctask<void, string, void> { textview mtextview; string mmessage; int mtypingdelay; typertask(textview textview, string message, int typingdelay) { this.mtextview = textview; this.mmessage = message; this.mtypingdelay = typingdelay; } @override protected void doinbackground(void... params) { (int = 0; < mmessage.length(); i++) { publishprogress(string.valueof(mmessage.charat(i))); try { thread.sleep(mtypingdelay); } catch (interruptedexception e) { e.printstacktrace(); } } return null; } @override protected void onprogressupdate(string... typedchar) { mtextview.append(typedchar[0]); } }
here's how use it:
textview mytextview = (textview) findviewbyid(r.id.mytextview); new typertask(mytextview, "this test message.", 100).execute();
Comments
Post a Comment