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
show item
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?
Maybe I need to create a parent class myBase
that will extend activity and all my activities will extend him?
View is Display System of Android where you define layout to put subclasses of View in it eg. Buttons, Images etc. But Activity is Screen System of Android where you put display as well as user-interaction,(or whatever which can be contained in full-screen Window.)
Layout is where you organize the views in your page. But without activity, they have no meaning. Because in activity, you have to get these views and use them programmaticaly. All together, you load views from layout to activity and in activies you implement your whole program.
Class - A class is a combination of methods, variables and data types. Every Java or Android project must have at least one class. Activity - An Activity is an android class. If we want to use an activity class, we must use extend Activity in your android project.
A View in Android is a widget that displays something. Buttons, listviews, imageviews, etc. are all subclasses of View. When you say "change view" I assume you mean change the layout by using setContentView(). This usually only needs to be done once per activity. An Activity is basically what you are referring to as a screen. To answer your question, it sounds like you need four separate activities (one for each screen).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With