作业帮 > 综合 > 作业

Android出错The application has stopped unexpectedly

来源:学生作业帮 编辑:搜搜做题作业网作业帮 分类:综合作业 时间:2024/04/27 12:58:18
Android出错The application has stopped unexpectedly
刚开始学Android,编了一个简单的程序,代码如下就出现上面的错误了.是什么原因啊
public class Hello extends Activity {
/** Called when the activity is first created.*/
private Button myButton = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myButton = (Button)findViewById(R.id.myButton);
myButton.setText(R.string.welcome);
}
}
Android出错The application has stopped unexpectedly
没有错的啊,我刚也给你编译过了,你看下是不是main.XML文件中你的Button的id写错了.如果不行自己看下logcat是那出错了,不行就把logcat给我贴出来,我帮你看.