How to implement MVC in Android

Updated on technology 2024-03-31
3 answers
  1. Anonymous users2024-02-07

    MVC, MVP and MVVM are the three common architectural design patterns, and the current use of MVP and MVVM is relatively widespread, of course, MVC is not outdated.

    MVC (Model-View-Controller), a standard MVC looks like this:

    Jian You said:

    Cons:

    MVP (Model-View-Presenter) is an evolved version of MVC, and the main parts are as follows:

    Brief Description:

    Explanation:

    Pros:

    Disadvantages: Bending

    mvvm is shorthand for model-view-viewmodel. Compared with the MVP pattern, the MVVM pattern replaces the presenter with the viewmodel, and the other layers are basically the same as the MVP pattern, and the viewmodel can be understood as a combination of the data model and presenter of the view. Embedding MVVM abstracts the state and behavior of the view in it, allowing us to separate the view UI from the business logic.

    Brief Description:

    Cons:Reference:

  2. Anonymous users2024-02-06

    MVC (Model View Controller) MVC applications always consist of these three parts. event causes the controller to change the model or view, or both.

    As soon as the controller changes the data or properties of the models, all dependent views will be automatically updated. Similarly, as long as contro

  3. Anonymous users2024-02-05

    Phase 1. Using traditional MVC, the view corresponds to various layout files, but these layout files are not as powerful as the web side, and what can be done is very limited; The controller corresponds to the activity, and the activity has the function of manipulating the UI, we will also have a lot of UI operations in the actual project at this layer, and also do a lot of things that should be done in the view, of course, the controller also contains the things that the controller should do, such as the distribution of various events, and in the first layer, we will call the model layer to operate the data according to the event, Therefore, in the actual project, the controller where the activity is located is very heavy, and the coupling between the layers is also serious, which is inconvenient for unit testing.

    Phase II. Using the evolution version of MVC - MVP, the layout layout and activity are used as the view layer in MVP, and the presenter layer is added, and the presenter layer interacts with the model layer for business interaction, and then interacts with the view layer (that is, activity) to refresh the UI after completion. In this way, all the work of business logic is handed over to the presenter, which reduces the coupling between the view layer and the model layer, and simplifies the work in the activity. However, in actual projects, as the complexity of logic increases, the shortcomings of activity bloat are still reflected, because the activity is still full of a large number of unrelated to the view layer, such as the processing and distribution of various events, just like in MVC, the view layer and the controller** are coupled together and cannot extricate themselves.

    Phase 3.

Related questions
24 answers2024-03-31

The operating system of Android mobile phones is similar, taking Huawei mobile phones as an example, you can try the following screenshot methods: >>>More

8 answers2024-03-31

There is a similar article in the Lecheng Mobile Developers Alliance.

5 answers2024-03-31

On the Windows 7 development platform, the Android Studio development tools use the following methods to limit the maximum number of characters that can be entered in EditText. >>>More

6 answers2024-03-31

The identity framework automatically creates the membership tables we need to manage our users, so we don't need to worry about creating them in advance.

13 answers2024-03-31

2. In the second step, if you want to get the brand of the phone or tool you are debugging, you can use brand. >>>More