Android Studio activities question

  • Thread starter kolleamm
  • Start date
324
28
I noticed that when making apps there's activities which are the different classes and then there's the layout pages which are the different pages you see when using the app.

My question is, is the standard to create one class/activity that handles most of layout pages, or a class/activity for each layout page?
 
32,389
4,152
I noticed that when making apps there's activities which are the different classes and then there's the layout pages which are the different pages you see when using the app.

My question is, is the standard to create one class/activity that handles most of layout pages, or a class/activity for each layout page?
I'm not an Android programmer, so caveat emptor...

It's a common practice in programming in general to separate the code that presents the user interface (layout pages in your case) from the code that performs the actions. That way, the user interface can be customized for a variety of devices with different UIs without having to make changes to whatever actions need to be carried out.
 
324
28
I'm not an Android programmer, so caveat emptor...

It's a common practice in programming in general to separate the code that presents the user interface (layout pages in your case) from the code that performs the actions. That way, the user interface can be customized for a variety of devices with different UIs without having to make changes to whatever actions need to be carried out.
Hi you may have misunderstood what I mean. I wasn't referring to the code that generates the layout page. I was referring to whether each layout page should have its own class, or if there should be a single class that controls all the pages, function wise.
 
32,389
4,152
Hi you may have misunderstood what I mean. I wasn't referring to the code that generates the layout page. I was referring to whether each layout page should have its own class, or if there should be a single class that controls all the pages, function wise.
A reasonable partition of things would be a top-level class that contains all of the properties and methods that are common to all pages, together with more specialized classes that would inherit from the top-level class. The specialized classes would take care of the differences between one page and another.

If two pages are identical, though, I don't see any reason for each page having its own class.
 
324
28
A reasonable partition of things would be a top-level class that contains all of the properties and methods that are common to all pages, together with more specialized classes that would inherit from the top-level class. The specialized classes would take care of the differences between one page and another.

If two pages are identical, though, I don't see any reason for each page having its own class.
Makes sense, I agree with the two page thing. Thanks!
 

Want to reply to this thread?

"Android Studio activities question" You must log in or register to reply here.

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top