从 SurfaceView 线程更新 EditText LayoutParams?
我在 onCreate 的主要活动中创建了一个 EditText 对象。我需要能够从 SurfaceView 线程更改布局参数。目前我收到此错误:
android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
我还尝试从 UIHandler 设置布局参数,但收到相同的错误。我对 Android 开发非常陌生,所以我非常感谢任何建议。谢谢!
I have a EditText object created in the main activity in onCreate. I need to be able to change the layout parameters from a SurfaceView thread. Currently I am getting this error:
android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
I also tried setting the layout parameters from a UIHandler but I get the same error. I am really new to Android dev, so I would greatly appreciate any suggestions. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一般来说,您可以使用 runOnUiThread 从不同的线程更新 UI。例如
In general you can use
runOnUiThread
to update the UI from a different thread. e.g.