I have 3 fragments. The first time I view the 3rd Fragment everything works as expected. When I go to the first fragment and then resume or go back to the 3rd fragment the OnItemClickListener's in the ListView that is on that fragment no longer work. If I swipe left and move the 3rd fragment a little the OnItemClickListener's start working again. Any Idea as to why this would be the case?
mListView.setOnItemClickListener(OnItemClickListener { parent, view, position, id ->
Log.d("DEBUG", "xyz")
})
I tried moving the setOnItemClickListener for the ListView into the onResume function thinking that maybe the setOnItemClickListener's were lost each time the fragment was shown, but after this did not correct the issue and finding the swipe trick, I moved the setOnItemClickListener back to the onViewCreated function.
UPDATE: I am not sure why but I reset the adapter manually in the override of the onResume and it seemed to correct the issue...
class FragmentAtoZ : Fragment(R.layout.fragment_atoz) { private lateinit var viewModel: ItemViewModel private lateinit var mListView: ListView private lateinit var arrayAdapter: ArrayAdapter<*> private lateinit var sounds : MutableList private lateinit var btnPause: Button private lateinit var btnStop: Button
override fun onStart() {
super.onStart()
}
override fun onResume() {
super.onResume()
mListView.adapter = arrayAdapter
}
... }