title: OnWindowFocusChanged and onCreate - Android
body: <p>I am trying to setup the UI elements programatically. <br/> I am able to setup the UI elements in <strong>onWindowFocusChanged</strong> method?  <br/>The question i want to ask  is - shall i setup the UI elements in the <strong>onCreate</strong> method or on <strong>onWindowFocusChanged</strong>? The code -<br/><br/> </p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.baselayout);
  }
  </code></pre>
  
  <p>And<br/></p>
  
  <pre><code>@Override
  public void onWindowFocusChanged(boolean hasFocus) {
      // TODO Auto-generated method stub
      super.onWindowFocusChanged(hasFocus);
      if (hasFocus) {
          res = getResources();
          inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
          setUpBackgroundImage();// setting up the background image
          setUpTopMenu(); // Setting up the menu on top
          setUpLogo(); // Setting up the Logo
      }
  }
  </code></pre>
  
  <p>Is the above approach correct?</p>