// 当该Fragment被添加,显示到Activity时调用该方法 // 在此判断显示到的Activity是否已经实现了接口 @Override public void onAttach(Activity activity) { super.onAttach(activity); if (!(activity instanceof HomeFragment.BindToolbarCallBack)) { throw new IllegalStateException( "TitlesListFragment所在的Activity必须实现TitlesListFragmentCallBack接口"); } bindToolbarCallBack = (BindToolbarCallBack) activity; }
// 当该Fragment从它所属的Activity中被删除时调用该方法 @Override public void onDetach() { super.onDetach(); bindToolbarCallBack = null; }
@Override public void onPause() { super.onPause(); // actToolbar.setVisibility(View.VISIBLE); }
@Override public void onDestroyView() { super.onDestroyView(); ButterKnife.unbind(this); }