title: Call a method when fragment is visible to user
body: <p>I need execute a method when the fragment is visible (to the user).</p>
  
  <p>Example:
  I have 2 buttons (button 1 and button 2) ,
  2 fragments(fragment 1 and fragment 2)
  and the method <code>loadImages()</code> inside the class fragment 2.</p>
  
  <p>when I press "button2" I want to replace fragment 1 by fragment 2
  and then after the fragment 2 is visible (to the user) call <code>loadImages()</code>.</p>
  
  <p>I tried to use <code>onResume()</code> in the fragment class but it calls the method before the fragment is visible and it makes some delay to the transition.</p>
  
  <p>I tried <code>setUserVisibleHint()</code> too and did not work.</p>
  
  <p>A good example is the Instagram app. when you click on profile it loads the profile activity first and then import all the images. </p>
  
  <p>I hope someone can help me. I will appreciate your help so much. Thank you.</p>