在 Eclipse 中将 Activity 添加到 Android 项目的最佳方法? [英] Best way to add Activity to an Android project in Eclipse?

查看:23
本文介绍了在 Eclipse 中将 Activity 添加到 Android 项目的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

向现有 Android 项目添加活动时,我手动创建了一个新类 - 这是最好/首选的方式吗?其他人是怎么处理的?

When adding an activity to an existing Android project, I manually create a new class - is that the best / preferred way? How do others handle that?

推荐答案

您可以使用新建类"对话框,但需要手动执行其他步骤(例如,向清单文件添加条目).如果您希望这些步骤自动化,您可以通过清单编辑器创建活动,如下所示:

You can use the "New Class" dialog, but that leaves other steps you need to do by hand (e.g. adding an entry to the manifest file). If you want those steps to be automated, you can create the activity via the manifest editor like this:

  1. 在包资源管理器中双击 AndroidManifest.xml.
  2. 点击清单编辑器的应用程序"标签
  3. 点击应用程序节点"标题下的添加.."(屏幕左下角)
  4. 从弹出的对话框中的列表中选择 Activity(如果有选项,您想创建一个新的顶级元素)
  5. 点击属性"标题下的名称*"链接(窗口右下角)为新活动创建一个类.

当您从新课程对话框中单击完成"时,它将带您进入新的活动课程,以便您开始编码.

When you click Finish from the new class dialog, it'll take you to your new activity class so you can start coding.

五个步骤可能看起来很多,但我只是想在这里更加详细,以便清楚.实际操作时非常快.

Five steps might seem a lot, but I'm just trying to be extra detailed here so that it's clear. It's pretty quick when you actually do it.

这篇关于在 Eclipse 中将 Activity 添加到 Android 项目的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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