如何处理Android应用程序中的多种布局
我是 Android 新手,我需要一些提示来了解如何创建更改布局的简单应用程序(对于布局,我的意思是屏幕上显示的内容)。
每个应用程序都有按钮,例如,如果按下按钮,则将应用程序移动到另一个布局,在这里我可以执行一些操作然后返回(例如短信应用程序)。当布局更改时,我是否必须启动另一个活动?或者我可以做主要活动中的所有事情吗?当我做这种事情时,android 是如何工作的?
我在哪里可以读到相关内容?你有教程吗?你有例子吗?谢谢!!
I'm a noob in android, and I need some hints to understand how to create simple applications that change layout (for layout I mean what appers on the screen).
Every application has buttons for example that, if pressed, move the app to another layout and here I can do something an then come back (for example the sms app). when layout changes, do I have to start another activity? Or can I do everithing in the main activity? How android does work when I do this kind of things?
Where can I read something about it? do you have tutorials? do you have examples? thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这实际上取决于您的应用程序。在 Android 上,Activity 的作用远不止显示小部件的层次结构,因此您可以使用单个 Activity 并在不同布局之间切换,或者将您的应用程序真正实现为多个 Activity。
由于您是初学者,我建议您在每次屏幕要更改布局时写下一个新的 Activity。最终,如果您认为两个或多个 Activity 确实是同一功能,您将能够合并它们
It really depends on your app. On Android an Activity does much more than showing a hierarchy of widgets, so you may use a single Activity and switch between different layouts or really implement your app as multiple Activities.
Since you are a beginner, I suggest you to write down a new Activity every time your screen is supposed to change layout. Eventually, you'll be able to merge two or more Activity if you think that they are indeed the same piece of functionality