How to use classes in android

426 views Asked by At

im not new to programming and to android at all, but I have a little problem. I can make some good apps work, but I fell like im not working very good with the classes issue. For Example, if I have a background that moving , or any other animations, I will always put the code in the MainActivity. And I have seen some projects which have class named "background animation" or "missle falling class" that making some missles fall in the background . So the problem is that I will always put the code in the main activity. I know how to use classes, but this is a problem for me, i dont know when to put the code on another class or not. thank you . I will tell more so you will understand. When you making a game in android, you probably will have class for your "game" or game class, and I dont have one. I know I need it, but I have no idea how to connect the whole game to one class. Did you understand ? thank you !!

1

There are 1 answers

0
Leandro Borges Ferreira On

I think your question is more suited for this page: https://softwareengineering.stackexchange.com/.

But you want a answer right? You should try the MVP architecture, it's a good one.

You will find a good example here: https://github.com/antoniolg/androidmvp

And the explanation: http://antonioleiva.com/mvp-android/

I think those examples will teach you how to separate the your classes and your interfaces.