A view uses the model indirectly to generate an appropriate user interface (for example, the view lists the shopping cart's contents). The view gets its own data from the model. The model and controller have no direct knowledge of the view.
The user interface waits for further user interactions, which restarts the cycle.
Java Swing is different from the other frameworks in that it supports two MVC patterns:
Frame level model—Like other frameworks, the design of the real model is usually left to the developer.
Control level model—Swing also supports models on the level of controls (elements of the graphical user interface). Unlike other frameworks, Swing exposes the internal storage of each control as a model.
View : The view is represented by a class that inherits from Component.
Controller : Java Swing doesn't use a single controller. Because its event model is based on interfaces, it is common to create an anonymous action class for each event. In fact, the real controller is in a separate thread, the Event dispatching thread. It catches and propagates the events to the view and model.
The latter facet of the adapter system is not that different from other GUI toolkits' ways of overriding default display behavior.
For example, in Java/Swing, if you want a JList-backed listbox to actually be a checklist (where individual rows are a checkbox plus label, and clicks adjust the state of the checkbox), you inevitably wind up calling setCellRenderer() to supply your own ListCellRenderer, which in turn converts strings for the list into JCheckBox-plus-JLabel composite widgets.
However, if your activity is dominated by a single list, you might well consider creating your activity as a subclass of ListActivity, rather than the regular Activity base class. (so that the program is shorter)
If your main view is just the list, you do not even need to supply a layout – ListActivity will construct a full-screen list for you.
If you do want to customize the layout, you can, so long as you identify your ListView as @android:id/list, so ListActivity knows which widget is the main list for the activity.
Get a View that displays the data at the specified position in the data set.
You can either create a View manually or inflate it from an XML layout file.
When the View is inflated, the parent View (GridView, ListView...) will apply default layout parameters unless you use inflate(int, android.view.ViewGroup, boolean) to specify a root view and to prevent attachment to the root.