Sorry!The application Menu02(process com.amaker.test)has stopped unexpectedly.Please try again.
   Force close

解决方案 »

  1.   

    logcat显示 :
    04-19 07:55:51.602: D/AndroidRuntime(757): Shutting down VM
    04-19 07:55:51.602: W/dalvikvm(757): threadid=1: thread exiting with uncaught exception (group=0x40015560)
    04-19 07:55:51.631: E/AndroidRuntime(757): FATAL EXCEPTION: main
    04-19 07:55:51.631: E/AndroidRuntime(757): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.amaker.test/com.amaker.test.MainActivity05}: java.lang.ClassCastException: android.widget.TextView
    04-19 07:55:51.631: E/AndroidRuntime(757):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
    04-19 07:55:51.631: E/AndroidRuntime(757):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
    04-19 07:55:51.631: E/AndroidRuntime(757):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
    04-19 07:55:51.631: E/AndroidRuntime(757):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
    04-19 07:55:51.631: E/AndroidRuntime(757):  at android.os.Handler.dispatchMessage(Handler.java:99)
    04-19 07:55:51.631: E/AndroidRuntime(757):  at android.os.Looper.loop(Looper.java:123)
    04-19 07:55:51.631: E/AndroidRuntime(757):  at android.app.ActivityThread.main(ActivityThread.java:3683)
    04-19 07:55:51.631: E/AndroidRuntime(757):  at java.lang.reflect.Method.invokeNative(Native Method)
    04-19 07:55:51.631: E/AndroidRuntime(757):  at java.lang.reflect.Method.invoke(Method.java:507)
    04-19 07:55:51.631: E/AndroidRuntime(757):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    04-19 07:55:51.631: E/AndroidRuntime(757):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    04-19 07:55:51.631: E/AndroidRuntime(757):  at dalvik.system.NativeStart.main(Native Method)
    04-19 07:55:51.631: E/AndroidRuntime(757): Caused by: java.lang.ClassCastException: android.widget.TextView
    04-19 07:55:51.631: E/AndroidRuntime(757):  at com.amaker.test.MainActivity05.onCreate(MainActivity05.java:18)
    04-19 07:55:51.631: E/AndroidRuntime(757):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    04-19 07:55:51.631: E/AndroidRuntime(757):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
    04-19 07:55:51.631: E/AndroidRuntime(757):  ... 11 more
      

  2.   

    clean了以后,还是一样的问题,不能解决阿
      

  3.   

    点Project-->clean-->ok ,你是这样操作的吗
      

  4.   

    java.lang.ClassCastException: android.widget.TextView问题出在TextView上,检查下布局文件里TextView 和你activity里id是否对应
      

  5.   

    main.xml<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        ><TextView android:id="@+id/TextView01" 
              android:layout_width="wrap_content" 
              android:layout_height="wrap_content" 
              android:text="@string/str1"></TextView>
    <Button android:id="@+id/Button01" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:text="@string/str2"></Button>
    </LinearLayout>
     
      

  6.   

    MainActivity05的源码也发上来看一下
      

  7.   

    package com.amaker.test;import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.Toast;
    public class MainActivity05 extends Activity{
    private Button b1,b2; @Override
    protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    b1=(Button)findViewById(R.id.TextView01);
    b2=(Button)findViewById(R.id.Button01);
    final int l=Toast.LENGTH_LONG;
    final int s=Toast.LENGTH_SHORT;
    final String s1="我多显示一会儿";
    final String s2="我少显示一会儿";
    b1.setOnClickListener(new OnClickListener()  {
    public void onClick(View v){
    Toast t1=Toast.makeText(getApplicationContext(), s1, s);
    t1.show();
    }
    });
    b2.setOnClickListener(new OnClickListener() {
    public void onClick(View v){
    Toast t2=Toast.makeText(getApplicationContext(), s2, l);
    t2.show();
    }
    });
    }
    }编译可以通过,运行时虚拟设备就不能通过
      

  8.   

    晕倒 
    private Button b1,b2;
    应该改为private TextView b1;
    private Button b2;
      

  9.   

    b1=(Button)findViewById(R.id.TextView01);
    改为
    b1=(TextView)findViewById(R.id.TextView01);
      

  10.   

    你把TextView当Button用,当然报错啊
      

  11.   

    要修改main.xml<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:orientation="vertical"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       ><Button android:id="@+id/TextView01"  
      android:layout_width="wrap_content"  
      android:layout_height="wrap_content"  
      android:text="@string/str1"></Button>
    <Button android:id="@+id/Button01"  
      android:layout_width="wrap_content"  
      android:layout_height="wrap_content"  
      android:text="@string/str2"></Button>
    </LinearLayout>
     
      

  12.   

    我的也是这种错误,可是我clean了。也没有把TextView用错,还有什么办法吗?求解》》》》》》》》》》