Why doesn't “setContentView” work in if statement?
<p>the code is in onCreate! when <code>setContentView(R.layout.manual);</code> is outside the <code>if</code> it works. But I moved <code>setContentView(R.layout.manual);</code> into <code>if</code> can’t work!</p>

<p>The followign:</p>

<pre><code>if (settings.getBoolean("my_first_time", true)) { 
    setContentView(R.layout.manual); // can not work
}  
</code></pre>

<p>But <code>Log.d("Comments1", "First time");</code> always works</p>

<pre><code>    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final String PREFS_NAME = "MyPrefsFile";
    SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
    if (settings.getBoolean("my_first_time", true)) {

        //the app is being launched for first time, do something 

        Log.d("Comments1", "First time");//this can be showed on logCat!

        setContentView(R.layout.manual);// this can not work 

        // record the fact that the app has been started at least once
        settings.edit().putBoolean("my_first_time", false).commit(); 
        }

}
</code></pre>
