How to run Android activity

Source: Internet
Author: User

Android Basic activity programming is basically written in three parts, namely the layout XML file under the Res/layout directory, the Java file under the src/package, and the Androidmanifest.xml file in the Res directory.

This is the three documents, the basic process is in layout. The XML file defines the interface layout, Then the Java file (a Java file represents an activity) makes a call to the Layout.xml file, writes the active principal code, and finally registers the activity in Androidmanifest.xml, and sets the primary activity (that is, the first activity opened by default). Like this.

First in First_layout. The XML layout file defines a button, the button ID is set to button_1, and the button name is set to 1.

Then override the OnCreate method in the Firstactivity.java file to load the first_layout. The XML layout file (OnCreate () method is the method that runs each time the activity is created and can be interpreted as a method of active initialization)

Requestwindowfeature (Window.feature_no_title) This line is to remove the active title bar because it takes up too many positions

You can see the space or save a large part of it. Of course, just writing to this step will not work, because you also need to go to the Androidmanifest.xml file to register the firstactivity activity.

Can see, ". Firstactivity "is actually the abbreviation for" com.test.blogtest.FirstActivity "because it is already in the same package by default, so it only needs to write". Firstactivity "It's OK.

The following Android:label is the title bar, can be seen at a glance, right.

The general activity does not need to define <intent_filter> this part, except the activity which needs certain starting condition, for example this is defines it as the main activity.

You can run the event here.

"Learn the first line of code." The next day

How to run Android activity

Related Article

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.