package com.china.hello;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public
class HelloChina extends Activity {/**
Called
when
the
activity
is
first
created.
*/@Overridepublic
void onCreate(Bundle saveInstanceState) {super.onCreate(saveInstanceState);//setContentView(R.layout.main);TextView tv = new TextView(this);tv.setText("helloWorld");setContentView(tv);}
}
下载的是android2.2;
运行后出现一个手机界面不过说:The application has stopped unexpectedly, please try again ;
高手指点下...

解决方案 »

  1.   

    从这看来,程序没什么错。如果报错的话,看下错误日志报的什么错。
    我估计你的清单文件有错(AndroidManifest.xml);
    activity的中的android:name=""参数 是不是不是HelloChina 。
      

  2.   


    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.china.hello"
        android:versionCode="1"
        android:versionName="1.0" >    <uses-sdk android:minSdkVersion="8" />    <application
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name" >
            <activity
                android:name=".HelloWorldActivity"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
        </application></manifest>没错吧
      

  3.   

    明显错了,你的activity叫HelloChina,manifest里面写成HelloWorldActivity了
      

  4.   


    有错。。你看这一句:
    android:name=".HelloWorldActivity"
    它说明你要运行的Activity的名字应该是HelloWorldActivity。。你看你的程序里面那个Activity的名字是HelloChina。。程序运行的时候,它根据HelloWorldActivity这个名字来找,当然会找不到,就要报错,应该要报什么classNotFound的异常。
    你把名字改一下,随便你改程序里的还是清单文件的,一样就行。
    Ps:以后你写程序,每自己写了一个Activity,都需要在清单文件里面注册。
      

  5.   

    是这段代码出错了:TextView tv = new TextView(this);
    tv.setText("helloWorld");
    setContentView(tv);setContentView的参数只能是View类型,而tv是View下的控件,不能直接用,需要修改一下:
    TextView tv = new TextView(this);
    tv.setText("helloWorld");
    tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); LinearLayout linearlayout = new LinearLayout(this)
    linearlayout.addView(tv);
    setContentView(linearlayout);
      

  6.   

    6楼应该没有问题的吧!在清单文件错了android:name=".HelloWorldActivity",要和你的java 类名一致
      

  7.   


    TextView不是继承View?又是java不学好跑来弄android的。。lz还真被你误导了