I am creating an android app. It is my first “real” android app that I’m creating and I’m also new to Java. I have never created any program with OOP before so I’m a little confused with the structure of things. I have some PHP, experience but I initially learned to program with Turbo Pascal which was procedural (inline?).
Anyway… Here is the situation:
- Main Activity – This is the activity for controlling the actual Android app that I have.
-
class ScoreClock – This is where i have the following methods:
public ScoreClock // initialize all the fields(variables) within the ScoreClock class. public getMinutes(long ms) // take ms remaining and calculate minutes left. public getSeconds(long ms) // take ms remaining and calculate seconds left.
Now… I’m thinking of adding public void updateBoard() which would be for updating all of the values to the actual scoreboard. What I’m confused with is… Should the updateBoard() method go into the MainActivity.java file or the ScoreClock.java file?
The updateBoard method will be accessing the android fields/variables and changing the values of TextViews and such, so I’m thinking that it should be placed in MainActivity.java.
Could someone please clarify?
All code to update UI elements goes in the Activity or View itself. You can’t access any of that from the POJO. It sounds like you, like so many, are trying to make a game. I would suggest you learn Java first, then Android, THEN try to make a game. Don’t start with something as complicated as a game.