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
- 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)
- <?xml version="1.0" encoding="utf-8" >
- <resources>
- <drawable name="darkgray">#808080FF</drawable>
- <drawable name="white">#FFFFFFFF</drawable>
- </resources>
(2) define the String constant strings. xml)
- <? Xml version = "1.0" encoding = "UTF-8">
- <Resources>
- <String name = "hello"> Hello World Android </drawable>
- <String name = "app_name"> Test Android </drawable>
- <String name = "str_id"> account </drawable>
- <String name = "str_pwd"> password </drawable>
- </Resources>
There are two reference methods:
1) Tag reference: android: text = "@ string/str_id"
2) code reference:
- Resources resources = getBaseContenxt (). getResources ();
- Drawable HippoDrawable = resources. getDrawable (R. drawable. white );
- // String aa = resources. getString (R. string. app_name );
- // String bb = getString (R. string. app_name );
- TextView TV = (TextView) findViewByID (R. id. text );
- TV. setBackground (HippoDrawable );
- // Of course, you can use the default android Color graphics. Color, but there are only 12 common colors.
- /×
- Color. BLACK
- Color. BLUE
- Color. CYAN
- Color. DKGRAY
- Color. GRAY
- Color. GREEN
- Color. LIGRAY
- Color. MAGENTA
- Color. REN
- Color. TRANSPARENT
- Color. WHITE
- Color. YELLOW
- ×/
- View sourceprint? 1 7. Get the resolution of the mobile phone
- 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.
- View sourceprint? 1 DisplayMetrice dm = new DisplayMetrice ();
- GetWindowManager (). getDefaultDisplay (). getMetrice (dm );
- String strOpt = "cell phone resolution:" dm. widthPixels + "x" + dm. heightPixels;