RecyclerView1

単純に
recyclerView.adapter?.notifyDataSetChanged()
を実行すると
 CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. 
 というエラーメッセージで落ちる。 
 対応としては 
 this.runOnUiThread(Runnable {
     recyclerView.adapter?.notifyDataSetChanged()
 }) 
 みたいな感じにしたらいけた。 
AndroidStudioの推奨?でRunnableを消したらエラーになる。

シェアする

  • このエントリーをはてなブックマークに追加

フォローする