Android official document Learning

Source: Internet
Author: User

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.

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.