MVC pattern on Android

Is it possible to implement the model–view–controller pattern in Java for Android?

Or is it already implemented through Activities? Or is there a better way to implement the MVC pattern for Android?


In Android you don't have MVC, but you have the following:

  • You define your user interface in various XML files by resolution, hardware, etc.
  • You define your resources in various XML files by locale, etc.
  • You extend clases like ListActivity, TabActivity and make use of the XML file by inflaters.
  • You can create as many classes as you wish for your business logic.
  • A lot of Utils have been already written for you - DatabaseUtils, Html.

  • There is no universally unique MVC pattern. MVC is a concept rather than a solid programming framework. You can implement your own MVC on any platform. As long as you stick to the following basic idea, you are implementing MVC:

  • Model: What to render
  • View: How to render
  • Controller: Events, user input
  • Also think about it this way: When you program your model, the model should not need to worry about the rendering (or platform specific code). The model would say to the view, I don't care if your rendering is Android or iOS or Windows Phone, this is what I need you to render. The view would only handle the platform-specific rendering code.

    This is particularly useful when you use Mono to share the model in order to develop cross-platform applications.


    The actions, views and activities on Android are the baked-in way of working with the Android UI and are an implementation of the model–view–viewmodel (MVVM) pattern , which is structurally similar (in the same family as) model–view–controller.

    To the best of my knowledge, there is no way to break out of this model. It can probably be done, but you would likely lose all the benefit that the existing model has and have to rewrite your own UI layer to make it work.

    链接地址: http://www.djcxy.com/p/30222.html

    上一篇: 复合视图和复合演示文稿

    下一篇: Android上的MVC模式