Beginner's journey to Android (2) beginner's questions

Source: Internet
Author: User

1. Add and run the control, but there is a main. Out. xml always reports an error, saying there is no content

Cause: Unlike vs, eclipse is closely related to the files currently opened, so there is a problem. Switch to the Java file and run it. Reference

2. How to add an activity

Activity is a form. Open androidmanifest. xml. In the application view, you can see

Before adding a class, you must create a corresponding class.

After adding the content:

Call the new window:

Intent I = new intent ();
I. setclass (add2.this, newact. Class );
Startactivity (I );
Add2.this. Finish ();

If newact. java is a copy of add2.java, so the two forms will share a set of interfaces. to separate them, we need to create a new interface in layout (you can Ctrl-C, Ctrl-V and then modify it)

ModifyCodeSetcontentview (R. layout. main2.

3. If you get the reference of the added Control

The added control contains the property description ID in the XML file of layout, Android: Id = "@ + ID/TTT ". At the same time, there will be corresponding properties in R. Java, which can be used to reference the control.

4. Create a class

The new class is located in the same space under the gen directory and can be called directly.

5. You can use the scroll bar to view how to display a long text.

In Main. XML, scrollview is used instead of linearlayout.

6. Meaning of class name. This

When this is used in the internal class, it refers to the internal class object. To access the outer class object, you can use the outer class name. This to access it. See

7. For applicationsProgramSet background

1) create a PNG Image

2) stored in the drawable-hdpi folder

3) refresh the project and you should be able to see the file. At the same time, the project should exist in R. java.

4) Right-click the main. XML design interface, select Properties -- background, and select BK resource.

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.