请朋友来帮忙看看吧!运行自己写的Activity出错了?

chuanwei2007 2009-11-10 11:22:24

public class app2 extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

Button button=(Button)findViewById(R.id.submit);
button.setOnClickListener(myName);

}
private OnClickListener myName=new OnClickListener(){
public void onClick(View v) {

EditText editText=(EditText)findViewById(R.id.name);
TextView textView=(TextView)findViewById(R.id.result);
textView.setText(editText.getText()+"!"+"Welcome to join the Android");

Intent intent=new Intent();
intent.setClass(app2.this,Welcome.class);
startActivity(intent);

}
};

}

1.应用程序名为Hello Android2
2.应用包名为com.android2
3.我通过app2.class调用自己写的Activity的Welcome.class
4.出错Error:应用程序Hello Android2(在进程com.android2中)意外停止。请重试!
5.请问朋友们遇到过这种情况吗?
6.怎么修改?
...全文
171 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
yitiaochongzi 2009-11-11
  • 打赏
  • 举报
回复
在AndroidManifest.xml里面添加Welcome没有
AngleProgrammer 2009-11-11
  • 打赏
  • 举报
回复
配置文件里添加
<activity android:name="Welcome" />
  • 打赏
  • 举报
回复
相关的xml做了配置么?
chuanwei2007 2009-11-11
  • 打赏
  • 举报
回复
已经为所有回复的朋友加分啦!~~谢谢大家的时间啦!
chuanwei2007 2009-11-11
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 zhouyongyang 的回复:]
要加上
<activity android:name = ".Welcom"
          android:label = "@String/Welcom_label"/>

你在程序中用到的activity都要配置上面的信息
[/Quote]

zhouyongyang:您好,谢谢!可以运行啦~~
chuanwei2007 2009-11-11
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 herbert5069 的回复:]
1. 在AndroidManifest.xml

中添加
<activity android:name = ".Welcom"
          android:label = "@String/Welcom_label"
/>

2. 在 /res/values/strings.xml 中定义Welcom_label 为自己想要的标题字符串
[/Quote]
herbert5069您好:我的程序中只配置了app2,所以出错!按照你的做法,添加了配置.可以运行了!
谢谢啦!给你加分!

zhouyongyang 2009-11-11
  • 打赏
  • 举报
回复
要加上
<activity android:name = ".Welcom"
android:label = "@String/Welcom_label"/>

你在程序中用到的activity都要配置上面的信息
herbert5069 2009-11-11
  • 打赏
  • 举报
回复
1. 在AndroidManifest.xml

中添加
<activity android:name = ".Welcom"
android:label = "@String/Welcom_label"
/>

2. 在 /res/values/strings.xml 中定义Welcom_label 为自己想要的标题字符串

80,492

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧