Android notifyDataSetChanged()
我使用后台Android notifyDataSetChanged(),android,android-recyclerview,notifydatasetchanged,Android,Android Recyclerview,Notifydatasetchanged,我使用后台线程获取数据,并使用处理程序将数据应用到回收视图 当我将数据应用到RecyclerView时,我使用notifyDataSetChanged() 这是我的线程和处理程序 inner class APIHandler() : Handler() { override fun handleMessage(msg: Message) { super.handleMessage(msg) val bundle: Bun
线程
获取数据,并使用处理程序
将数据应用到回收视图
当我将数据应用到RecyclerView
时,我使用notifyDataSetChanged()
这是我的线程
和处理程序
inner class APIHandler() : Handler() {
override fun handleMessage(msg: Message) {
super.handleMessage(msg)
val bundle: Bundle = msg.data
if (!bundle.isEmpty) {
// Handler applies the data to the RecyclerView using notifyDataSetChanged().
}
}
}
inner class APIThread() : Thread() {
var stopFlag: Boolean = false
override fun run() {
while (!stopFlag) {
val message: Message = APIHandler.obtainMessage()
val bundle: Bundle = Bundle()
// Thread gets the data here.
message.data = bundle
upbitAPIHandler.sendMessage(message)
sleep(200)
}
}
}
有时,即使单击某个项目,也会出现单击事件未被处理的情况
我认为这种情况是通过notifyDataSetChanged()
发生的
因为在我的代码中,notifyDataSetChanged()
每200ms调用一次
但是,我无法延长调用notifyDataSetChanged()
的周期
有没有办法解决单击事件被忽略的情况
如果忽略单击事件的原因不是因为notifyDataSetChanged()
,请告诉我原因
谢谢你阅读这篇文章