Android setContentView not being applied
<p>Hi I'm this is a reask of a previous question just because i wasn't clear before. i have  a json feed that consists which i found the length of the array in it. as it should it produces one. but what i'm trying to do is if a second item were to be added that feed another layout would need to be used.</p>

<p>so i currently have a string that contains the String value of YES this is then sent in an intent to anther activity this is placed inside an if statement that says if x = Yes then use layout1 if x = no use layout2. </p>

<p>the problem i'm having is when i put a string in the if statement and log it it works but when i put setContentView in and it forces the app to close why?</p>

<p>here is my code</p>

<p>in the 1st activity</p>

<pre><code>HttpResponse response = client.execute(post);
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
String json = reader.readLine();

JSONObject obj = new JSONObject(json);


JSONObject objData = obj.getJSONObject("data");

JSONArray jArray = objData.getJSONArray("structure");

leagueCount = jArray.length();


if (leagueCount == 1){                   
   teamFeedStructure = "YES" ; 
}        
if (leagueCount == 2){
   teamFeedStructure = "NO" ; 
}                        
</code></pre>

<p>now the intent sent</p>

<pre><code>Intent mainIntent = new Intent(firstActivity.this,secondActivity.class);

mainIntent.putExtra("leagueCount", teamFeedStructure);

firstActivity.this.startActivity(mainIntent);

firstActivity.this.finish();
</code></pre>

<p>now in the second Activity</p>

<pre><code>@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    //setContentView(R.layout.introact);

    String leagueCount = getIntent().getExtras().getString("leagueCount");

    //String leaguecount = String.valueOf(leagueCount);

    Log.v("lc", leagueCount);

    if (leagueCount == "YES"){

        String one = "one";
        setContentView(R.layout.introact);

        Log.v("lc", one);       
    }

    //if (leaguecount == "2"){

       //setContentView(R.layout.introact);
    //}
</code></pre>

<p>The Error</p>

<pre><code>04-23 21:53:34.455: W/dalvikvm(954): threadid=1: thread exiting with uncaught exception (group=0x40015560)
04-23 21:53:34.465: E/AndroidRuntime(954): FATAL EXCEPTION: main
04-23 21:53:34.465: E/AndroidRuntime(954): java.lang.RuntimeException: Unable to start activity ComponentInfo{co.uk.fantasticmedia.TheEvoStikLeague/co.uk.fantasticmedia.TheEvoStikLeague.IntroActivity}: java.lang.NullPointerException
04-23 21:53:34.465: E/AndroidRuntime(954):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
04-23 21:53:34.465: E/AndroidRuntime(954):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-23 21:53:34.465: E/AndroidRuntime(954):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-23 21:53:34.465: E/AndroidRuntime(954):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-23 21:53:34.465: E/AndroidRuntime(954):  at android.os.Handler.dispatchMessage(Handler.java:99)
04-23 21:53:34.465: E/AndroidRuntime(954):  at android.os.Looper.loop(Looper.java:130)
04-23 21:53:34.465: E/AndroidRuntime(954):  at android.app.ActivityThread.main(ActivityThread.java:3683)
04-23 21:53:34.465: E/AndroidRuntime(954):  at java.lang.reflect.Method.invokeNative(Native Method)
04-23 21:53:34.465: E/AndroidRuntime(954):  at java.lang.reflect.Method.invoke(Method.java:507)
04-23 21:53:34.465: E/AndroidRuntime(954):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-23 21:53:34.465: E/AndroidRuntime(954):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-23 21:53:34.465: E/AndroidRuntime(954):  at dalvik.system.NativeStart.main(Native Method)
04-23 21:53:34.465: E/AndroidRuntime(954): Caused by: java.lang.NullPointerException
04-23 21:53:34.465: E/AndroidRuntime(954):  at co.uk.fantasticmedia.TheEvoStikLeague.IntroActivity.onCreate(IntroActivity.java:45)
04-23 21:53:34.465: E/AndroidRuntime(954):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-23 21:53:34.465: E/AndroidRuntime(954):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
04-23 21:53:34.465: E/AndroidRuntime(954):  ... 11 more
</code></pre>
