Home > Net >  Can I use single input form to collect data from multiple Activities in Android Studio?
Can I use single input form to collect data from multiple Activities in Android Studio?

Time:10-23

So hello everyone! Greetings for the day!

There are serveral Activities in Android studio I have to get data with. Total of 6 data inputs. However one user enters data for only one of them.

Here's the design sketch. https://ibb.co/X5yyzQM

So do I have to design 6 Activities with input forms like this or is there any method to use one input form to use for 6 activities and get data with unique form value to the database?

Like BanquetStarter(name, address..) , BanquetBronze(name, address..) etc.

Appreciate your kind help. Appologies for your valuable time. Thanks ❤.

CodePudding user response:

These are separate screens, but do not necessarily have to be separate activities. Consider architecting this with Fragments. This would allow you to utilize a single ViewModel bound to the lifecycle of the Activity. Each fragment would be responsible for collecting its own information and handing that into the ViewModel, 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).

  • Related