Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/224.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android notifyDataSetChanged()_Android_Android Recyclerview_Notifydatasetchanged - Fatal编程技术网

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()
,请告诉我原因

谢谢你阅读这篇文章