Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
作为一个 android 编程的新手,我被建议使用适配器和处理程序来定期更新 textview 而不是线程/睡眠。但是,我想知道为什么!有什么建议么?
在 Android 中,您无法在 UI 线程之外更新 UI 小部件,因此Handler提供了一种Thread与 UI 通信的方式。在这种方法中,您启动线程以生成视图数据并将其传递给Handler通过Message. 然后,处理程序根据您发送的数据更新 UI。
Handler
Thread
Message
我不确定适配器在什么地方适合等式,因为它们通常用于将某些数据与视图(例如ListView和ListAdapter)连接起来。
ListView
ListAdapter