英文:
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活动对话框中选择空视图活动。
英文:
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.
答案2
得分: 0
请在创建空白活动时选择生成布局文件复选框,我还附上了屏幕截图,请检查。
英文:
Please select generate layout file checkbox when you are creating empty activity and i also attach screen short please check
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论