Android Studio activities question

  • Thread starter Thread starter kolleamm
  • Start date Start date
  • Tags Tags
    Android
AI Thread Summary
In Android app development, it's common to separate user interface code from action code for flexibility across devices. The discussion revolves around whether to use a single class for multiple layout pages or to create individual classes for each layout. A recommended approach is to have a top-level class that contains shared properties and methods, with specialized subclasses for unique pages. If two pages are identical, there's no need for separate classes. This structure enhances code organization and maintainability.
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 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 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 sysprog
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Thread 'Project Documentation'
Trying to package up a small bank account manager project that I have been tempering on for a while. One that is certainly worth something to me. Although I have created methods to whip up quick documents with all fields and properties. I would like something better to reference in order to express the mechanical functions. It is unclear to me about any standardized format for code documentation that exists. I have tried object orientated diagrams with shapes to try and express the...
Back
Top