title: How do I control focus and scroll position when a fragment is returned to (onResume not called)?
body: <p>I have 3 tabs in a ViewPager in my main activity. When I return to Tab 1 from Tab 2, I'd like to scroll to the top and put focus in the first EditText. However, Tab 1's <code>onResume</code> fragment method is not being called, so where can I set the view? Thanks.  </p>
  
  <p>Here is the code in my Activity where I set the <code>onPageChangeListener</code>.  </p>
  
  <pre><code>mViewPager.setOnPageChangeListener(
              new ViewPager.SimpleOnPageChangeListener() {
                  @Override
                  public void onPageSelected(int position) {
                      getActionBar().setSelectedNavigationItem(position);
                      mPagerAdapter.getItem(position).onResume(); // trying to call onResume
                  }
              });
  </code></pre>
  
  <p>This is my Fragment's <code>onCreate</code></p>
  
  <pre><code>@Override
  public View onCreateView(LayoutInflater inflater,
          ViewGroup container, Bundle savedInstanceState) {
  
      rootView = inflater.inflate(
              R.layout.fragment_new_grade_calc, container, false);
  
      context = this.getActivity();
  
      bindAll();     // map ScrollView and other views as Java Objects
      setListeners(); // set listeners for objects
  
      if(savedInstanceState != null){
          setRestoredViews(savedInstanceState);
      } else
          setInitialViews(); 
  
  
      return rootView;
  }
  </code></pre>
  
  <p>My Fragment's <code>onResume</code></p>
  
  <pre><code>@Override
  public void onResume(){
      super.onResume();
      final ScrollView sv = (ScrollView) rootView.findViewById(R.id.scrollview_new_grade);
           // ^^this is what gets the NullPonterException
  
      sv.post(new Runnable() {
          @Override
          public void run() {
              sv.fullScroll(ScrollView.FOCUS_UP);
          }
      });
  }
  </code></pre>