在Android清爽滚动字幕文本 [英] Refreshing Marquee Text on Android
本文介绍了在Android清爽滚动字幕文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在推出后,我的滚动字幕文本工作正常。然后我想更新somewhen文本。我互联网上获取文本,并将其设置为TextView的:
marqueeText.setText(Html.fromHtml(GetNew.getNews()));
有没有关于从互联网上获取文本问题。但随后的文本不会滑动。是什么样的,这个问题?感谢您的帮助。
编辑:我得到这个日志时尝试刷新。我刷新它在一个线程。
一十月6日至12日:25:04.403:E /标签(498):只有创建视图层次可以触摸其观点原来的线程。
解决方案
您应该使用处理程序的UI线程的工作。
专用处理器处理器=新的处理程序(新的回调(){ 公共布尔的handleMessage(消息MSG){
marqueeText.setText(Html.fromHtml(GetNew.getNews()));
marqueeText.setSelected(真);
marqueeText.setEllipsize(TruncateAt.MARQUEE);
返回false;
}
});
而当你要更新线程的文本,然后使用 handler.sendEmptyMessage(0);
On launch, my marquee text is working normally. Then i want to update text in somewhen. I get text on internet and set it to textview:
marqueeText.setText(Html.fromHtml(GetNew.getNews()));
There is no problem about getting text from internet. But then the text is not sliding. What is the problem about that? Thanks for your help.
Edit: I get this log when try to refresh it. I refresh it in a thread.
06-12 10:25:04.403: E/tag(498): Only the original thread that created a view hierarchy can touch its views.
解决方案
You should use the handler for working on UI thread.
private Handler handler = new Handler(new Callback() {
public boolean handleMessage(Message msg) {
marqueeText.setText(Html.fromHtml(GetNew.getNews()));
marqueeText.setSelected(true);
marqueeText.setEllipsize(TruncateAt.MARQUEE);
return false;
}
});
And when you want to update the text in thread then use handler.sendEmptyMessage(0);
这篇关于在Android清爽滚动字幕文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文