大家好!今天大家好!
在Android Studio中有几个活动我必须获得数据。总共6个数据输入。但是一个用户只为其中一个输入数据。
这是设计草图。
那么,我是否必须使用这样的输入表单来设计6个活动,或者是否有任何方法可以使用一个输入表单来用于6个活动,并将具有唯一表单值的数据导入数据库?
如BanquetStarter(名称、地址..)、BanquetBronze(名称、地址..)等。
感谢您的帮助。感谢您宝贵的时间。谢谢。
大家好!今天大家好!
在Android Studio中有几个活动我必须获得数据。总共6个数据输入。但是一个用户只为其中一个输入数据。
这是设计草图。
那么,我是否必须使用这样的输入表单来设计6个活动,或者是否有任何方法可以使用一个输入表单来用于6个活动,并将具有唯一表单值的数据导入数据库?
如BanquetStarter(名称、地址..)、BanquetBronze(名称、地址..)等。
感谢您的帮助。感谢您宝贵的时间。谢谢。
1条答案
按热度按时间gpnt7bae1#
These are separate screens, but do not necessarily have to be separate activities. Consider architecting this with
Fragment
s. This would allow you to utilize a singleViewModel
bound to the lifecycle of theActivity
. Each fragment would be responsible for collecting its own information and handing that into theViewModel
, and then once all the information is submitted, you have it all in one place and ready to go.Activities are heavy weight components, whereas Fragments are lighter weight. Unless you have a very good, explicit reason to do so, prefer a single activity approach with multiple fragments (or multiple composable screens, if this app is being written from scratch utilizing Jetpack Compose).