title: Opening a new activity on button click
body: <p>I have looked at every example of switching between activities and I always get the same result.  The app bombs.</p>
  
  <p>As far as I can tell if you have a java class that populates the content of a layout then in order to switch to the other layout, you must 'link' to the java file which in turn will open the setContentView(R.layout.whatever);</p>
  
  <p>When I try to do this, like I say my app bombs out.  My code is as follows:-</p>
  
  <p>FROM Java class:-</p>
  
  <pre><code>    @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState); 
  
      requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
  
      setContentView(R.layout.activity_main);
  
      Button next = (Button) findViewById(R.id.goesnews);
      next.setOnClickListener(new View.OnClickListener() {
          public void onClick(View view) {
              Intent myIntent = new Intent(view.getContext(), ac2.class);
              startActivityForResult(myIntent, 0);
          }
  
      });
  
      getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);   
  
  
  
  
  }
  </code></pre>
  
  <p>TO java file (ac2)</p>
  
  <pre><code>     public class ac2 extends Activity {
  
       /** Called when the activity is first created. */
       public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.main2);
  
       }}
  </code></pre>
  
  <p>Can anyone help out here?</p>