OnWindowFocusChanged和onCreate – Android

我正在尝试以编程方式设置UI元素。
我能够在onWindowFocusChanged方法中设置UI元素?
我想问的问题是 – 我应该在onCreate方法或onWindowFocusChanged中设置UI元素? 代码 –

@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.baselayout); } 

 @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 } } 

上述方法是否正确?

Solutions Collecting From Web of "OnWindowFocusChanged和onCreate – Android"