I am reading ListFragment source code and I see this implementation:
ListAdapter mAdapter;
ListView mList;
View mEmptyView;
TextView mStandardEmptyView;
View mProgressContainer;
View mListContainer;
CharSequence mEmptyText;
boolean mListShown;
/**
* Detach from list view.
*/
@Override
public void onDestroyView() {
mHandler.removeCallbacks(mRequestFocus);
mList = null;
mListShown = false;
mEmptyView = mProgressContainer = mListContainer = null;
mStandardEmptyView = null;
super.onDestroyView();
}
In this function, Google developers set Null to all view fields that declared in ListFragment and remove callback 'mRequestFocus'.
In ListActivity source code. Google developers implemented like below:
protected ListAdapter mAdapter;
protected ListView mList;
private Handler mHandler = new Handler();
@Override
protected void onDestroy() {
mHandler.removeCallbacks(mRequestFocus);
super.onDestroy();
}
I didn't see Google developers set Null to mList on onDestroy of ListActivity as they did for ListFragment class.
My question is
Why google developers didnot set Null to mList in onDestroy of ListActivity? Any reasons?
Do we need to set Null to all View fields in Activity's onDestroy and Fragment's onDestroyView?
3. Any practices for set Null in these two functions: Activity's onDestroy and Fragment's onDestroyView?
Thank you for your ideas!