From official documents: http://developer.android.com/training
Official CHM: workshop!
API documentation: http://ishare.iask.sina.com.cn/f/11898230.html. It is easy to understand and must be developed.
Difference between Android: Text and Android: hint: Text Black Display and hint Gray Display
@ XX/YY: point to the resource in XML, @ string/edit_message
@ + ID/: used only when the resource ID is defined for the first time. @ + ID/button_send
If you do not create a default activity when creating a project, you must use intent-filter to register the default activity when running the program in manifest after creating the first activity.
<Activity
Android: Name = "com. example. myfirstapp. mainactivity"
Android: Label = "@ string/title_activity_main">
<Intent-filter>
<Action Android: Name = "android. Intent. Action. Main"/>
<Category Android: Name = "android. Intent. Category. launcher"/>
</Intent-filter>
</Activity>
Wake up another Activity from one Activity:
MainActivity:
Intent intent = new Intent (this, SecondActivity. class );
EditText editText = (EditText) findViewById (R. id. content );
String message = editText. getText (). toString ();
Intent. putExtra (EXTRA_MESSAGE, message );
StartActivity (intent );
SecondActivity:
Intent intent = getIntent ();
String message = intent. getStringExtra (MainActivity. EXTRA_MESSAGE );
TextView textView = new TextView (this );
TextView. setText (message );
SetContentView (textView );
Activity lifecycle:
One run: created-started-resumed -- paused-stopped-destroyedresumed status is the running status. Paused-onresume ()-resumed: The paused state is overwritten or translucent by other activities (visible to the current activity ). Stopped-onrestart ()-onstart ()-started: the stopped status is completely overwritten by other activities (the current activity is completely invisible ). Resumed: front-end display, interactive. Paused: The paused is partially blocked by other activities (the other activity does not cover the entire screen or translucent display). It is partially visible, interactive, and non-executable code. Stopped: it is completely invisible. The activity instance and status information are saved, but the Code cannot be executed. Some processes are quickly called by the system. For example, once oncreate () has an activity, the system will quickly call onstart () and then onresume () methods. The app startup activity is configured in androidmanifest. xml. Add intent-filter under activity, including main action and launcher category: <intent-filter>
<Action Android: Name = "android. Intent. Action. Main"/>
<Category Android: Name = "android. Intent. Category. launcher"/>
</Intent-filter>
If there is no full declaration for an Activity in AndroidManifest, the Activity icon will not appear in the program list of the mobile phone.
OnCreate (): the life cycle of an Activity is only executed once. variables in the class range are generally initialized here.
Onstop (): removes activity resources.