活动未找到厚望 [英] Activity Not Found Expection

查看:98
本文介绍了活动未找到厚望的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个选项菜单,其中有一个按钮,点击注册。上点击,我想去的RegisterActivity.java

I am trying to create a Option menu where there is a button to click register. on clicking that i want to go to the RegisterActivity.java

 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
  case R.id.register:
        Intent i = new Intent(this, RegisterActivity.class);
        startActivity(i);
        return true;
  case R.id.exit:

   return true;
  default:
   return super.onOptionsItemSelected(item);
  }

 }

http://variable3.com/files/screenshots/2010-12- 26_0034.png

推荐答案

你记得注册活动在Android清单xml文件? (这发生在我身上所有的时间)。如果你读ActivityNotFoundException这行文字的其余部分,它可能会问,如果你忘了注册。

Did you remember to register the activity in your android manifest xml file? (That happens to me all the time). If you read the rest of the text on the line that says ActivityNotFoundException, it would likely ask if you forgot to register it.

就在你的项目的根目录下这段文字添加到您的Andr​​oidManifest.xml文件:

Just add this text to your AndroidManifest.xml file in the root of your project:

<activity
    android:name=.[sub_package].RegisterActivity
/>

与任何包(相对于最低级封装差)你有更换[sub_package]。

Replacing [sub_package] with whatever package (relative to the lowest level package difference) you had.

所以,如果你有net.xyActivityA和net.xzRegisterActivity你会怎么做:

So if you had net.x.y.ActivityA and net.x.z.RegisterActivity you would do:

<activity
    android:name=.z.RegisterActivity
/>

这篇关于活动未找到厚望的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆