以定时增量附加滚动文本视图
我创建了一个滚动文本视图,并且能够添加文本并滚动得很好。问题是,我试图按时间间隔添加文本,并且用户可以通过点击屏幕底部的两个按钮之一来调整所述间隔。一切都已就位,但无论我做什么,我只能让它在整个持续时间后立即显示所有文本。假设我试图在十秒钟内每半秒添加一次文本。运行它十秒钟没有任何结果,然后一切都会显示出来。我尝试过使用计数器的 for/while 循环并通过系统时间进行跟踪。没有。递归很快就会破坏堆栈,这并不奇怪。使用 wait() 或 Thread.sleep() 不起作用,而且也不是理想的选择,因为按钮需要始终处于活动状态。在私有内部类中创建单独的线程不起作用,因为您无法触摸在另一个线程中创建的视图。尝试在单独的线程中创建自定义视图拒绝工作,原因我尚无法弄清楚。
我到底该怎么做才能实时添加每个条目?
I've created a scrolling textview and have been able to add text and scroll just fine. The thing is, I'm trying to add text at timed intervals and said interval can be adjusted by the user by hitting one of two buttons at the bottom of the screen. Everything is in place, but no matter what I do, I can only get it to display all of the text at once after the whole duration. Say I'm trying to add text every half second for ten seconds. Running it results in nothing for ten seconds, and then everything shows up. I've tried for/while loops with counters and keeping track via system time. Nope. Recursion blows the stack in no time, which wasn't much of a surprise. Using wait() or Thread.sleep() don't work and wouldn't be ideal anyway as the buttons need to be live at all times. Making a separate thread in a private inner class didn't work as you can't touch Views created in another thread. Trying to create a custom View in separate thread refused to work for reasons I can't figure out just yet.
How in the heck would I do this so each entry is added in real time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
就我而言,它可以很好地与一个 Timer 对象一起自动滚动
In My case It works Fine for Autoscroling along with one Timer object