When I write a Java program I always try to organize my code following the MVC pattern, in order to get a smooth and efficient program.
I’ve created an Android application and I was wondering if the MVC can be used.
I have thought that the Android code is a Java-derived code, so I’ve tried, but I have some problems to reconcile the Android activities (Views for the pattern) with the Controller.
The controller should catch user interactions with the app (button clicked, write label…) and refresh the View with new information obtained by the Model. So, what can I do and eventually the MVC can be used in Android applications?
When I write a Java program I always try to organize my code following
Share
The Android framework already provides many pieces of MVC.
You can think of
Activitiesas Controllers since they receive user input and allow you to change Views or route to other parts of your application usingIntents.Android’s
Viewsare the View part of MVC, and the data models are left up to you to implement.