Android页面Activity还是Layout?
我的应用程序由一个带有“开始”、“关于”等的介绍页面组成。
我通过让“开始”按钮调用一个定义了新的 onclick 侦听器的新布局,成功创建了该应用程序的功能版本。
这对我来说似乎不太清楚,我正在为我使用的每个布局定义一个新的 onClick 侦听器,并且想知道创建单独页面(包括我的“关于”和我实现的任何其他屏幕)的正确方法。
任何建议表示赞赏,谢谢。
My app Consists an intro page with "Start", "About", etc..
I managed to create a functional version of the app by having the "Start" button call a new layout in which a new onclick listener is defined.
This doesn't seem clean to me that I@m defining a new onClick listener for each Layout I use and wonder how the correct way would be to create individual pages (including my "About" and any other screens I implement).
Any advice is appreciated, thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该为每个“屏幕”创建一个活动。所有按钮都将启动相同的事件 (onClick),并且您将查看事件源视图的 ID 来启动正确的活动。
像这样的事情:
You should create an Activity for each "screen". All the buttons will launch the same event (onClick) and you will start the right activity looking at the ID of the event's source view.
Something like this: