如果我的Android Studio的空白活动未生成布局文件,我该怎么办?

huangapple go评论74阅读模式
英文:

What should I do if my Android Studio's empty activity is not generating the layout file?

问题

我在创建Android Studio上的空白活动时没有获得任何布局(.xml)文件。它被说成会自动创建,但我找不到activity_main.xml;我第一个项目没问题,但现在它不起作用了。

我已经尝试了从重新安装应用到删除旧项目的所有方法。我尝试了启动其他活动,它们都正常工作,但空白活动存在特定问题,而且我没有选择语言的选项;虽然它创建了一个.kt文件,但标志与我的第一个项目不同。如果有人能提供一个好的建议,那将非常有帮助。

英文:

I am not getting any layout(.xml) file while creating an empty activity on android studio. It is said to be created on its own but I can not find the activity_main.xml; It was alright for the first project that I made and it's somehow not working now.

I have tried every thing from reinstalling the app to deleting old projects. I tried to initiate other activities ,they all are working fine,but its a specific problem with empty activity, also I am not getting any option to choose my language; though it is creating a .kt file but the logo appears different from my first project. It would be of great help if anyone could provide a good advice.

答案1

得分: 1

在当前版本的Android Studio中,新建Android活动对话框 -> 空活动 将创建一个使用Jetpack Compose构建UI的活动,您需要编写可组合函数来描述UI,仅在YourNewActivity.kt文件中进行,不需要任何xml文件。

如果您尝试构建传统的视图系统(使用XML文件构建UI并查找findViewById等),您应该从新的Android活动对话框中选择空视图活动

如果我的Android Studio的空白活动未生成布局文件,我该怎么办?

英文:

In current version of Android Studio, New Android Activity dialog -> Empty Activity will create a Activity building the UI with Jetpack Compose, you have to write composable functions to describe the UI just in the YourNewActivity.kt file and without any xml file.

If you are trying to build traditional View system (which using the XML file to build UI and findViewById something), you should choose Empty Views Activity from the New Android Activity dialog.

如果我的Android Studio的空白活动未生成布局文件,我该怎么办?

答案2

得分: 0

请在创建空白活动时选择生成布局文件复选框,我还附上了屏幕截图,请检查。

英文:

Please select generate layout file checkbox when you are creating empty activity and i also attach screen short please check

huangapple
  • 本文由 发表于 2023年6月1日 11:48:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76378563.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定