Learning Android has a very important design idea is the--MVC design pattern.
The Application object is divided into three parts by model, controller, and view categories. Android apps are designed based on the model-controller-view (Model-view-controller, MVC) architecture pattern.
The MVC design pattern shows that any object that is applied, in the final analysis, belongs to the model object, the View object, and one of the control objects.
Model objects: Store data and business logic for your application. The View object knows how to draw on the screen how it responds to user input, such as the user's touch. The control object contains the logical unit of the application and is the link between the view and the model object.
Benefits of using MVC design Patterns:
Classifying Java classes as models, views, and control layers also helps us to design and understand applications.
Amount: Recently re-read the Android basics. Then bought a book called "Android Programming Guide" (second edition). Personal feeling this book is not bad. Write a simple procedure to contact in the book today.
I also changed some of my own compilation habits after reading this book. Because one of Android's most wanted compilation ideas is the MVC pattern, whether you're defining its name for a simple button or a bunch of buttons defining their information, think of this compilation idea.
When a user uses an app, when he clicks on a button, you want to respond to the click Time, you have to give the control to write its method, rather than a rigid button, is a vitality, has its own construction method of the button.
Let me draw an MVC data Flow diagram in response to user interaction:
The amount ... Although the picture is a little ugly, but the general meaning is a look.
The next step is to describe the activity's life cycle.
Each activity has its life cycle, and activity transitions between the three possible states of running, pausing, and stopping.
The life cycle, state, and state transitions of the activity system are called in the following ways:
1.onPause (), OnStop (), Ondestory (), OnCreate (), OnStart (), Onreasume ().
Logs track the life cycle of an activity:
The Android Android.util.Log class is able to send log messages to the system-level shared log Center. There are several logging methods in the Log class:
Among the most used are:
public static int D (String tag,string msg): Ddaibiao "Debug", used to represent the level of log information, the first parameter is the source of the log, and the second parameter represents the specific contents of the log.
The first parameter is usually passed in with a tag constant of the class name value.
private static final String tag= "mainactivity";
@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
LOG.D (TAG, "onCreate (Bundle) called");
Setcontentview (R.layout.activity_main);
}
Tip: @Override Note, the compiler is required to ensure that the current class has the method you want to overwrite.
Overwrite the Onsaveinstancestate (bundle) method, you can save some data in the bundle by this method, and then take the data out of the OnCreate () method.
When the user leaves the current Activity management user interface, or Android needs to reclaim memory, Acitivity is also destroyed, so for the user's experience, Android does not destroy the running activity in order to reclaim memory.
Activity may be destroyed only when it is paused or stopped
When developing with Android studio, it is important to look at the log logs.
Using the Android.util class to log information, you can control not only the contents of the log, but also the level of logging that is important to the information. Android supports five levels of logging:
1.ERROR:LOG.E (...) Description: Error
2.WARNING:LOG.W (...) Description: Warning
3.INFO:LOG.I (..) Description: Informational Message
4.DEBUG:LOG.D (...) Description: Debug output: May be filtered out
5.VERBOSE:LOG.V (...) Description: only for development.
In the development of the R file is a very annoying place, when you inadvertently to remove some of the R files inside the file, r file will be error, and then cause your entire project will be wrong, so the problem of dealing with R class is very important.
If you have some confusing error situations when compiling your resources, you might want to try these methods:
1. Re-check the validity of the XML file in the resource file
2. Cleanup Project
3. Synchronizing Items with Gradle
4. Run Android Lint
android--Foundation (2)