The first line of code reading notes 1+ Common error analysis

Source: Internet
Author: User

1. The view inside eclipse in Windows----Show views----other-----Android

2, need to master the use of Logcat

Logcat is the place where you find an oasis in the midst of a vast crowd, and you need to use it flexibly, and then we can print out the information we need without worrying about finding it.

We can also add filters ourselves, such as the following filter options:

3, in the creation of the menu file, the file header needs to change

The following is an error, such as the file <?xml version= "1.0" encoding= "Uft-8" >, which is not required.

If the above file with the first sentence, this sentence will be error, because the R file can not find this main.xml, so will error. The file structure is as follows:

Solution: Delete the first line of code.

Note: The layout label is not the same as the label for the menu

4, Intent two ways to jump

Explicit jump vs. implicit jump

Example:

StartActivity (Intent); The method used to start the activity

When we use the explicit jump above, our XML file only needs to be added:

<activity android:name= ". xxxx"/>

And when we use implicit jumps, we need to add some action and content action and category.

As follows:

5, note the name of the component

@+id/button-3 It's wrong to write like this. R there will be an error in the file. Must be changed to @+id/button_3

?

6 , as do not update at startup SDK

7. Add a dependency package to eclipse

reference:http://www.cnblogs.com/kissazi2/p/3644848.html Add Android Compatibility Pack (V4, V7 AppCompat) to eclipse

?

Here's how to add the error:

?

We are adding a. jar file.

We need to download the. jar file from the Web and then copy it to the Android project, then create a new Libs folder in Eclipse and refresh it, or you'll never see it.

As shown below:

But the above is wrong. It should be the right thing to do.

Unzip the. Jar in the Android project and refresh it in Eclipse, then right----The build path----add to path. This adds dependency completion.

?

8. There is only one way to completely copy the as project to eclipse

That is to copy the code, create a new class and package under Eclipse, and import it in.

The main difficulty is that the R file cannot be processed. Incomplete and cannot be repaired.

9, the life cycle of the activity

Activity A Activity B activity C

If you start activity B in a, then a experiences---onpause----onstop, b experiences oncreate----onstart----onresume

Press the back key in B to return to a, then a experience---onrestart---onstart---onresume b experience onpause---onstop-ondestroy

Pressing the home key in A is the same as starting activity B.

When you press the back key in a, a goes through onpause---onstop---ondestroy.

Of course, if there is a special situation, the phone suddenly shut down or the program suddenly restarted, then the user saved temporary data to do, at this time we should use Onsaveinstancestate to store these temporary variables.

?

?

10. Four modes of activity

Standard, single top, single task, single Instance

Android:launchmode= "Singletask" >

11. Use of third-party libraries

For third-party libraries, we have two ways to use it:

    1. Call the. Jar Package
    2. Call the entire project to make the entire project a library, provided that the entire project is free of errors. Hang up when there's a mistake.

12. Auto-complete function in eclipse

Reference article: http://www.cnblogs.com/dongritengfei/archive/2010/09/09/1822258.html

13, sometimes the package can not automatically fill the need to fill their own, there are times when the full complement of the package is the wrong package, we need to correct.

14. Gets the class name of the current instance

GetClass (). Getsimplename ();

?

15. Where is the genymotion adb?

E:/USERS/ZHUXUEKUI/APPDATA/LOCAL/ANDROID/SDK, let's change to eclipse and try it.

16. Fix the bug that prompted ' Running Android Lint ' after starting eclipse

The above is a good version of the problem, need to change to 20 or less. Target sdkvertion

17. Solve can ' t bind to local 8609 for debugger

Major or ADB error, we need to genymotion adb into and eclipse the following SDK, this problem does not appear. And we have to make sure that in one program, multiple

Adb.exe

?

18. Relative layout and linear layout

The linear layout pattern is few, the relative layout property is many.

We generally do not give the layout the name ID, because our controls inside the layout can be the layout bit parent control. Go directly by the relative.

However, in a relative layout, we can name the ID of a control, and then other controls can align with the control.

Reference article: http://www.jb51.net/article/43350.htm

19. Use of third-party libraries

Demo reference AppCompat, set as follows:

Instructions to add a lead in the demo:

Add this item as a library in AppCompat

?

20, the variable is the direct property of the control, the control is the carrier of the variable. In a class, a variable must be declared before it is used, or an error will be made.

Incorrect usage:

The first line of code reading notes 1+ Common error analysis

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.