android开发中的视图和活动有什么区别? [英] What is the difference between view and activity in android development?

查看:65
本文介绍了android开发中的视图和活动有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我什么时候需要创建一个新的活动,什么时候需要更改视图?

When do I need to create a new activity and when do I need to change the view?

我的应用程序需要执行以下操作:

My app needs to do:

两个大按钮(菜单的一种)

two big buttons(sort of menu)

项目列表-取决于上一个屏幕上的选择

list of items - depend on the selection on prev screen

另一个列表-取决于上一个屏幕上的选择

another list - depend on the selection on prev screen

显示项目

所有屏幕都必须具有相同的菜单菜单(最后一个具有另一个按钮)

All screens need to have the same menu menu (the last has another button)

我需要为每个屏幕创建一个活动还是只在同一活动中更改视图?

Do I need to create an activity for each screen or just change the view in the same activity?

也许我需要创建一个父类 myBase 来扩展活动,而我所有的活动都将扩展他?

Maybe I need to create a parent class myBase that will extend activity and all my activities will extend him?

推荐答案

您应该为屏幕创建单独的活动.Android通过从堆栈中弹出当前活动并显示最后一个活动来处理设备的后退按钮.因此,例如,如果用户要返回到屏幕2进行其他选择,则返回按钮可以执行此操作.

You should create separate activities for you screens. Android handles the back button of the device by popping the current activity out from the stack and displaying the last one. So if for example the user wants to return to screen 2 for another selection, the back button does this.

这篇关于android开发中的视图和活动有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆