android提示:很抱歉!应用程序xxxx(进程:xxx.xxx.xxx)意外停止,请重试 强行关闭

照着别人的代码写,总是会出现意想不到的惊喜 


<?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:layout_height="wrap_content"
		android:layout_width="wrap_content" 
		android:id="@+id/TextView01"
		android:text="杜鹃" >
		
	</textview>
</linearlayout>
<!-- <?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:layout_width="fill_parent" -->
<!-- android:layout_height="wrap_content" -->
<!-- android:text="@string/hello" /> -->
<!-- </LinearLayout> -->

  

上面没注释掉的开始是照着网上的代码写的,

下面的时候eclipse自动生成的代码

本来上面的很多,怎么改都编译不成功,就一直改,最后就改的跟下面的快一样了

当改的没错误的时候,一运行,模拟器就显示 应用程序意外停止。

最后终于改的一样了 ,却是linearlayout 和 textview 要写成 LinearLayout 和 TextView

很是郁闷啊

这个博客:http://android.yaohuiji.com/archives/386

里面贴的代码用小写, 到我这里就不行了。

貌似我贴上来的代码 引号也变成中文下的了?

-----------------------------------------------华丽分割线2011-03-25----18:19:21-------------------------------------

再次碰到引起意外停止的情况

//定义checkbox
final CheckBox cb1 = (CheckBox) findViewById(R.id.CheckBox01);
// 定义点击监听
        OnClickListener click = new OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                Toast.makeText(getApplicationContext(),
                        "点击" + ((ImageView) v).getId(), Toast.LENGTH_LONG).show();
//                Toast.makeText(getApplicationContext(),
//                          "点击" + ((Button) v).getId(), Toast.LENGTH_SHORT).show();
            }
            //点击要求起点落点都在同一范围(按钮)内?
        };
// 绑定监听
 cb1.setOnClickListener(click);

  


这样就会报错,采用注释的就可以正常运行,

Button, ImageView,ImageButton

CheckBox 用Button

ImageView/ImageButton用ImageView

否则出错。

-----------------------------------------------------分割2011-03-26----11:21:55---------------------------------

加个继承图

原文地址:https://www.cnblogs.com/ezhong/p/2171487.html