The MVC mode of Android

Source: Internet
Author: User

MVC (Model-view-controller): M refers to the logical model, v refers to the view model, and C is the controller:

Android also uses the more popular MVC framework in Android:

A. View layer: The general use of XML file interface description, when used can be very convenient to introduce. Of course, if you know more about Android, you can think of Android can also use javascript+html and other ways as the view layer, of course, there is a need for Java and JavaScript communication between, fortunately, Android provides an implementation of very convenient communication between them.

B. Control layer (Controller): The task of Android's control layer usually falls on the shoulders of many activities, which implies not to write code in activity, to be processed by activity delivery model business logic layer, as long as the other reason is Android The response time of the activity is 5s. If the time-consuming operation is put here, the program can easily be recycled.

C Model: The operation of the database, the operation of the network, etc. should be processed in the model, of course, business computing and other operations must be placed in the layer.

Data binding in the Android SDK also uses a similar approach to the MVC framework to display the data. Data binding is achieved by encapsulating the data in the control layer as required by the view model (that is, the adapter in the Android SDK) to be displayed directly on the view model. For example, the listactivity of all the data in the cursor, the view layer is a ListView, the data is encapsulated as ListAdapter, and passed to the ListView, the data is in the ListView reality.


The MVC mode of Android

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.