Code example for Fragment

Methods: getActivityonActivityCreated

0
    return v;
  } 
 
  @Override 
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
 
    // Use the parent activity to load the image asynchronously into the 
    // ImageView (so a single 
    // cache can be used over all pages in the ViewPager 
    if (ImageDetailActivity.class.isInstance(getActivity())) {
      mImageWorker = ((ImageDetailActivity) getActivity())
          .getImageWorker(); 
      mImageWorker.loadImage(mImageNum, mImageView);
    } 
 
    // Pass clicks on the ImageView to the parent activity to handle 
    if (OnClickListener.class.isInstance(getActivity())
        && Utils.hasActionBar()) { 
      mImageView.setOnClickListener((OnClickListener) getActivity());
    } 
  } 
 
  /** 
   * Cancels the asynchronous work taking place on the ImageView, called by the 
Connect your IDE to all the code out there  Get Codota for Java