eclipse 向 Android 项目添加一个新类

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5012004/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 15:47:52  来源:igfitidea点击:

Adding a new class to Android Project

androideclipse

提问by bo gusman

I'm a long time windows developer looking to learn something about Android programming. I'm working my way through the Sams book Teach Yourself Android Application Programming in 24 hours. I've discovered some flaws with the book already but nothing that I couldn't figure out on my own, until now. I'm working on adding a second class to my project and in the New Java Class dialog, it says to click the Browse button next to the Superclass box and pick "android.app.Activity". However, the only thing shown is java.lang.Object.

我是一个很长一段时间的 Windows 开发人员,希望了解有关 Android 编程的知识。我正在 24 小时内完成 Sams 的书“自学 Android 应用程序编程”。我已经发现了这本书的一些缺陷,但直到现在我都无法自己弄清楚。我正在向我的项目添加第二个类,在“新建 Java 类”对话框中,它说单击“超类”框旁边的“浏览”按钮并选择“android.app.Activity”。但是,唯一显示的是 java.lang.Object。

I'm pretty certain that I've set thing up correctly, but then, maybe I haven't.

我很确定我已经正确设置了东西,但是,也许我还没有。

Can anyone give me guidance?

谁能给我指导?

Thanks!

谢谢!

Bo

采纳答案by Squonk

The browse button tries to do an auto-match based on what is currently in the Superclass text box.

浏览按钮尝试根据超类文本框中当前的内容进行自动匹配。

Delete java.lang.Object and enter Act (for example) then click Browse and see what you get. ;-)

删除 java.lang.Object 并输入 Act(例如)然后单击 Browse 并查看您得到什么。;-)

BTW - I'm assuming you're using Eclipse? If so, confirm and someone will retag the question as it's more of an Eclipse usage question rather than Android specific.

顺便说一句 - 我假设你正在使用 Eclipse?如果是这样,请确认并且有人会重新标记该问题,因为它更像是一个 Eclipse 使用问题而不是特定于 Android 的问题。

回答by thisisananth

After creating a class you can just extend it ..

创建一个类后,你可以扩展它..

Create a class and then manually add the part in bold

创建一个类,然后手动添加粗体部分

public class MyActivity extends android.app.Activity{

公共类 MyActivity扩展 android.app.Activity{

}

}