Android - ListFragment onItemClick() invoked after onDestroyView()
Android's callback APIs are well sequenced and works as expected for most of the time. However, i ran into this problem where in a ListView's onItemClick() was invoked after the fragment's view was destroyed. Some search suggested that this could be because of the delay in processing Fragment Transactions, especially as they are posted to the main thread and executed in the next available slot and not immediately. But after spending some time in Fragment transaction, it turns out that this was an issue with frameworks's AbsListView. Besides, this was seen only with a ListView in a Fragment and not with other AdapterViews or custom views. As and when the Fragment is being destroyed, all the views attached to the activity window has to be detached. AbsListView has a custom logic when it is detached from the parent window, @Override protected void onDetachedFromWindow() { super.onDetachedFromWin...