安卓开发的新生,刚刚搭好eclipse和AVD等等东东,写了个hello,world程序,运行倒是成功了。
但是我把hello,world程序的输出改成“大家好”,AVD输出竟然还是“hello,world”,崩溃了,搜遍网上没找到为什么,哪位大神能指点一二。源代码如下
package helloworld.test;import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;public class HelloWorldActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TextView tv=new TextView(this); 
        tv.setText("大家好");    //原来是 tv.setText("hello,world!"); 
        setContentView(R.layout.main);
    }
}

解决方案 »

  1.   

    你看下res - values - strings 里是不是有各<string name="xxx">hello,world!</string>public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            TextView tv=(TextView)findviewbyid(R.id.xxx) 
            tv.setText("大家好"); 
            
        }
      

  2.   

    在AndroidManifest.xml中更改一下android:versionName(版本号)。
      

  3.   

    TextView tv=new TextView(this); 
            tv.setText("大家好");    //原来是 tv.setText("hello,world!"); 
    以上两句代码没有用的,你需要用findViewById(R.id.xxx)去对layout中的TextView设置文本,才会变的
      

  4.   

    楼上正解。你一开始的时候显示的hello,world!不是你new出来的textview上面的,需要绑定layout中的控件才能更改它。
      

  5.   

    也可以这样解决:
    public class HelloActivity extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
            TextView tv=new TextView(this); 
            tv.setText("大家好");    //原来是 tv.setText("hello,world!"); 
            setContentView(tv);
        }
    }