Android Studio activities question

  • Thread starter Thread starter kolleamm
  • Start date Start date
  • Tags Tags
    Android
Click For Summary

Discussion Overview

The discussion centers on the design approach for handling activities and layout pages in Android app development. Participants explore whether it is standard practice to create a single class/activity for multiple layout pages or to assign a separate class/activity for each layout page.

Discussion Character

  • Debate/contested
  • Technical explanation

Main Points Raised

  • Some participants suggest that it is common practice in programming to separate the user interface code from the action-performing code, allowing for easier customization across different devices.
  • Others clarify that the question pertains to whether each layout page should have its own class or if a single class should manage multiple pages.
  • A participant proposes a design where a top-level class contains common properties and methods, with specialized classes inheriting from it to handle differences between pages.
  • There is an agreement that if two pages are identical, there may be no need for separate classes for each page.

Areas of Agreement / Disagreement

Participants express differing views on the best approach to structuring classes and activities, with no consensus reached on a single standard practice.

Contextual Notes

Participants do not fully explore the implications of their proposed designs, and there may be assumptions regarding the complexity and functionality of the layout pages that are not explicitly stated.

kolleamm
Messages
476
Reaction score
44
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?
 
Technology news on Phys.org
kolleamm said:
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.
 
  • Like
Likes   Reactions: sysprog
Mark44 said:
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.
 
kolleamm said:
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.
 
  • Like
Likes   Reactions: sysprog and kolleamm
Mark44 said:
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!
 
  • Like
Likes   Reactions: sysprog

Similar threads

Replies
11
Views
3K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 1 ·
Replies
1
Views
5K
Replies
3
Views
1K
Replies
4
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 50 ·
2
Replies
50
Views
9K
  • · Replies 5 ·
Replies
5
Views
3K