在 Android Studio 中找不到 MainActivity.java

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30016492/
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-11-02 16:18:41  来源:igfitidea点击:

Cannot find MainActivity.java in Android Studio

javaandroidandroid-studiomain-activity

提问by Al_Stackoverflow

I am currently writing an Android App using Android Studio 1.2. However, i cannot find MainActivity.java file in it.

我目前正在使用 Android Studio 1.2 编写一个 Android 应用程序。但是,我在其中找不到 MainActivity.java 文件。

Hope someone can help me out.

希望有人可以帮助我。

Thanks in advance.

提前致谢。

Regards, Al

问候, 阿尔

回答by Kargavibe

I have Android Studio 1.2 too. In the left side:

我也有 Android Studio 1.2。在左侧:

  • Choose 1: Projectif it isn′t already open.
  • Then choose app, then java.
  • Then choose com.username.project.
  • Finally choose MainActivity.java.
  • 如果尚未打开,请选择1: Project
  • 然后选择app,然后java
  • 然后选择com.username.project
  • 最后选择MainActivity.java

回答by Jyotman Singh

Its not necessary that your file is named MainActivity.java. That is the default name. If you created the Java file with another name while making the project then that will be your main Activity file. It will have the name you gave while making the project.

您的文件不必命名为 MainActivity.java。这是默认名称。如果您在制作项目时使用另一个名称创建了 Java 文件,那么这将是您的主要活动文件。它将具有您在制作项目时提供的名称。

Otherwise just create a new activity and enter its name in the Manifest file to make it the main activity.

否则只需创建一个新活动并在清单文件中输入其名称以使其成为主要活动。

回答by Daniel Kuta

When you create new project select Blank Activity. MainActivity file is in Android -> app -> java -> your.package.name

创建新项目时,选择空白活动。MainActivity 文件在 Android -> app -> java -> your.package.name

回答by Zainab Hammami

Inside of android folder navigate to

在 android 文件夹内导航到

app --> src --> java --> com --> "your app name"

app --> src --> java --> com --> "your app name"