title: Application hanging in button's onClickListener
body: <p>My application hangs every time I clicked on a button I created. I tried to separate both Java code and they worked fine. Can anyone please help me to check? I just want to call the 2nd coding through the onClickListener. </p>
  
  <pre><code>public class MainActivity extends Activity{
      TextView aziangle,elevation,numberof,rightasc,decli,hourangle,solartime;
      Button goedit;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          initialize();   
      }
  
      private void initialize() {
          // TODO Auto-generated method stub
          aziangle=(TextView)findViewById(R.id.tvAziAngle);
          elevation=(TextView)findViewById(R.id.tvElevation);
          numberof=(TextView)findViewById(R.id.tvNumberof);
          rightasc=(TextView)findViewById(R.id.tvRightAsc);
          decli=(TextView)findViewById(R.id.tvDecli);
          hourangle=(TextView)findViewById(R.id.tvHourAngle);
          solartime=(TextView)findViewById(R.id.tvSolarTime);
          goedit=(Button)findViewById(R.id.bedit);
  
          goedit.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
                  switch(v.getId()) 
                  {
                  case R.id.bedit:
                      Intent ed=new Intent(MainActivity.this, Menu.class);
                      startActivity(ed);
                      break;
                  }
              }
          });
  
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  }
  
  public class Menu extends ListActivity {
      String selection[]={"Latitude","Longtitude","TimeZone","DaylightSavingTime","OffsetParameters"};
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setListAdapter(new ArrayAdapter&lt;String&gt;(Menu.this, android.R.layout.simple_list_item_1, selection));
  }
  
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
      // TODO Auto-generated method stub
      super.onListItemClick(l, v, position, id);
      String choosen= selection[position];
      try{
          Class ourclass = Class.forName("com.example.suntracking" + choosen);
          Intent ourintent=new Intent(Menu.this,ourclass);
          startActivity(ourintent);
      }catch(ClassNotFoundException e) {
          e.printStackTrace();
      }
  }
  }
  
  
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.suntracking"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk
          android:minSdkVersion="8"
          android:targetSdkVersion="18" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;activity
              android:name="com.example.suntracking.MainActivity"
              android:label="@string/app_name" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity
              android:name="com.example.suntracking.Menu"
              android:label="@string/app_name" &gt;
  
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>EDIT: I checked again and I'm pretty sure the problem is in the OnClickListener because as I delete those I can press the button and it wont hang, although it wont go to the other page as well.</p>
  
  <pre><code>11-19 21:48:27.262: D/TextLayoutCache(9308): Enable myanmar Zawgyi converter
  11-19 21:48:27.262: D/TextLayoutCache(9308): Enable myanmar Zawgyi converter
  11-19 21:48:27.262: D/TextLayoutCache(9308): Enable myanmar Zawgyi converter
  11-19 21:48:27.292: D/libEGL(9308): loaded /vendor/lib/egl/libEGL_adreno.so
  11-19 21:48:27.292: D/libEGL(9308): loaded /vendor/lib/egl/libGLESv1_CM_adreno.so
  11-19 21:48:27.292: D/libEGL(9308): loaded /vendor/lib/egl/libGLESv2_adreno.so
  11-19 21:48:27.292: I/Adreno-EGL(9308): &lt;qeglDrvAPI_eglInitialize:316&gt;: EGL 1.4 QUALCOMM build:  (CL4169980)
  11-19 21:48:27.292: I/Adreno-EGL(9308): OpenGL ES Shader Compiler Version: 17.01.10.SPL
  11-19 21:48:27.292: I/Adreno-EGL(9308): Build Date: 09/26/13 Thu
  11-19 21:48:27.292: I/Adreno-EGL(9308): Local Branch: 
  11-19 21:48:27.292: I/Adreno-EGL(9308): Remote Branch: 
  11-19 21:48:27.292: I/Adreno-EGL(9308): Local Patches: 
  11-19 21:48:27.292: I/Adreno-EGL(9308): Reconstruct Branch: 
  11-19 21:48:27.342: D/OpenGLRenderer(9308): Enabling debug mode 0
  11-19 21:48:27.372: D/TextLayoutCache(9308): Enable myanmar Zawgyi converter
  11-19 21:48:27.372: D/TextLayoutCache(9308): Enable myanmar Zawgyi converter
  11-19 21:48:27.372: D/TextLayoutCache(9308): Enable myanmar Zawgyi converter
  11-19 21:48:28.253: D/AndroidRuntime(9308): Shutting down VM
  11-19 21:48:28.253: W/dalvikvm(9308): threadid=1: thread exiting with uncaught exception (group=0x418f9898)
  11-19 21:48:28.253: E/AndroidRuntime(9308): FATAL EXCEPTION: main
  11-19 21:48:28.253: E/AndroidRuntime(9308): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.suntracking/android.view.Menu}; have you declared this activity in your AndroidManifest.xml?
  11-19 21:48:28.253: E/AndroidRuntime(9308):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1645)
  11-19 21:48:28.253: E/AndroidRuntime(9308):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1441)
  11-19 21:48:28.253: E/AndroidRuntime(9308):     at android.app.Activity.startActivityForResult(Activity.java:3464)
  11-19 21:48:28.253: E/AndroidRuntime(9308):     at android.app.Activity.startActivityForResult(Activity.java:3425)
  11-19 21:48:28.253: E/AndroidRuntime(9308):     at com.example.suntracking.MainActivity.onClick(MainActivity.java:47)
  11-19 21:48:28.253: E/AndroidRuntime(9308):     at android.view.View.performClick(View.java:4475)
  11-19 21:48:28.253: E/AndroidRuntime(9308):     at android.view.View$PerformClick.run(View.java:18786)
  11-19 21:48:28.253: E/AndroidRuntime(9308):     at android.os.Handler.handleCallback(Handler.java:730)
  11-19 21:48:28.253: E/AndroidRuntime(9308):     at android.os.Handler.dispatchMessage(Handler.java:92)
  11-19 21:48:28.253: E/AndroidRuntime(9308):     at android.os.Looper.loop(Looper.java:137)
  11-19 21:48:28.253: E/AndroidRuntime(9308):     at android.app.ActivityThread.main(ActivityThread.java:5419)
  11-19 21:48:28.253: E/AndroidRuntime(9308):     at java.lang.reflect.Method.invokeNative(Native Method)
  11-19 21:48:28.253: E/AndroidRuntime(9308):     at java.lang.reflect.Method.invoke(Method.java:525)
  11-19 21:48:28.253: E/AndroidRuntime(9308):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
  11-19 21:48:28.253: E/AndroidRuntime(9308):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
  11-19 21:48:28.253: E/AndroidRuntime(9308):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>Sorry, I don't really know how to post logcat, these are things that I saw in my program's logcat.</p>
  
  <p>This is the MainActivity xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      android:weightSum="100" &gt;
      &lt;LinearLayout 
          android:orientation="vertical"
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:layout_weight="95"&gt;
  
      &lt;TextView
          android:id="@+id/tvDay"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:text="TextView" /&gt;
  
      &lt;TextView
          android:id="@+id/tvDate"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:text="TextView" /&gt;
  
      &lt;TextView
          android:id="@+id/tvTime"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:text="TextView" /&gt;
  
  
      &lt;TextView
          android:id="@+id/tvAziAngle"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_alignParentTop="true"
          android:text="TextView" /&gt;
  
      &lt;TextView
          android:id="@+id/tvElevation"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/textView1"
          android:layout_below="@+id/textView1"
          android:text="TextView" /&gt;
  
      &lt;TextView
          android:id="@+id/tvNumberof"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/textView2"
          android:layout_below="@+id/textView2"
          android:text="TextView" /&gt;
  
      &lt;TextView
          android:id="@+id/tvRightAsc"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignRight="@+id/textView3"
          android:layout_below="@+id/textView3"
          android:text="TextView" /&gt;
  
      &lt;TextView
          android:id="@+id/tvDecli"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/textView4"
          android:layout_below="@+id/textView4"
          android:text="TextView" /&gt;
  
      &lt;TextView
          android:id="@+id/tvHourAngle"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/textView5"
          android:layout_below="@+id/textView5"
          android:text="TextView" /&gt;
  
      &lt;TextView
          android:id="@+id/tvSolarTime"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/textView6"
          android:layout_below="@+id/textView6"
          android:text="TextView" /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;Button
          android:id="@+id/bedit"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:text="Edit" 
          android:layout_weight="5"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I also tried making the 2nd activity as simple as only setcontent view, but still the same problem occurred.</p>