Android 2.1 Study Notes (1)

Source: Internet
Author: User

AndroidAfter upgrading 2.0 to Android 2.1, you will get the following updates: 3D image libraries, voice input, news and weather plug-ins, improved locking modes, and pinch-to-zoom. Of course, the live wallpapers that people have been very concerned about before will also be added to Android 2.1 of Droid. However, MOTO will also make its Droid have a certain personality. For example, they will not join the 3D Program Interface in Nexus One, but this is quite good, now we want to get the Android 2.1 push earlier.

1. Establish the environment

 
 
  1. Ubuntu+eclipse+ADT 

2. Is Android startup slow?

No way, it is really slow. Wait. It is generally said that it will not be closed after the first time, but the deployment will be much faster in the future. After testing, it is indeed faster. What I cannot accept most is that even clicking the Home Key is very slow.

3. R. layout. main cannot be resolved

This error occurs when I write a row, so I have no temper to find the cause.

Solution:

1) Delete "import android. R" in the third row. Note: I don't know when to add it.

2) Check "Project-> Build Automatically" in Eclipse"

Cause analysis:

1) after "import andorid R" is deleted, the project is automatically generated from the/res folder. The resources are parsed in my room; otherwise, it will be searched from the Android Resource class.

When using Eclipse for Java development, we should first note that its compilation is intelligent. Go to Preferences and enable dynamic Build workbench> Build automatically ). In this way, every time we save a file, Eclipse will automatically compile the file that is dependent on the file. Therefore, when we want to run an application, it is basically saved and the latest version. It can save a lot of time when processing large code volumes.

4. Layout

The book I bought is based on the previous version (Android SDK 1.0r2). The layout of the control is android: layout_x = "61px". Now I want android: layout_marginLeft = "61px" is written in this way, otherwise it will not work. Curious, it must also be a px value. Otherwise, the compiler will report an error and the compiler will be able to recognize the content in the string! Really powerful.

5. to display the URL in TextView, add android: autoLink = "all" to the TextView node"

6. Constant res \ values) This folder defines all constants used in the project. It is a good habit of programming.. For example:

1) define a color constant (color. xml)

 
 
  1. <?xml version="1.0" encoding="utf-8" >    
  2.  <resources>    
  3.      <drawable name="darkgray">#808080FF</drawable>    
  4.      <drawable name="white">#FFFFFFFF</drawable>    
  5.  </resources>  

(2) define the String constant strings. xml)

 
 
  1. <? Xml version = "1.0" encoding = "UTF-8">
  2. <Resources>
  3. <String name = "hello"> Hello World Android </drawable>
  4. <String name = "app_name"> Test Android </drawable>
  5. <String name = "str_id"> account </drawable>
  6. <String name = "str_pwd"> password </drawable>
  7. </Resources>

There are two reference methods:

1) Tag reference: android: text = "@ string/str_id"

2) code reference:

 
 
  1. Resources resources = getBaseContenxt (). getResources ();
  2. Drawable HippoDrawable = resources. getDrawable (R. drawable. white );
  3. // String aa = resources. getString (R. string. app_name );
  4. // String bb = getString (R. string. app_name );
  5. TextView TV = (TextView) findViewByID (R. id. text );
  6. TV. setBackground (HippoDrawable );
  7. // Of course, you can use the default android Color graphics. Color, but there are only 12 common colors.
  8. Color. BLACK
  9. Color. BLUE
  10. Color. CYAN
  11. Color. DKGRAY
  12. Color. GRAY
  13. Color. GREEN
  14. Color. LIGRAY
  15. Color. MAGENTA
  16. Color. REN
  17. Color. TRANSPARENT
  18. Color. WHITE
  19. Color. YELLOW
  20. ×/
 
 
  1. View sourceprint? 1 7. Get the resolution of the mobile phone
  2. View sourceprint? 1. This is the difference between Android and ios. This system is used by different mobile phone manufacturers, and the machines created are of different sizes. Apple's system is only used by him, so it can be unified.
  3. View sourceprint? 1 DisplayMetrice dm = new DisplayMetrice ();
  4. GetWindowManager (). getDefaultDisplay (). getMetrice (dm );
  5. String strOpt = "cell phone resolution:" dm. widthPixels + "x" + dm. heightPixels;


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.