1. When importing a new Android project, a red exclamation point appears on the project name, and the program cannot run.
Cause: the package path pointed to in classpath in the project is incorrect.
Solution: Right-click the project name and select properties, and then select the libraries option in Java bulid path. The path marked with red X is the Error Path. After deletion, use add external jars to add the correct path. Click OK and refresh it in package explorer.
2. When you click the android option in properties in eclipse, "the currently displayed page contains invalid values" appears ".
Cause: the project has lost the default. properties file.
Solution: copy a new default. properties file from another project and modify the target value in the file. Or, rename project. properties under the project root directory to default. properties.
3. After a new project is introduced, the android. jar file is lost.
Solution: Right-click the project name, select Properties, select Android, select a Project Build target, and click OK. If there is a problem, right-click the project name, select Android tools and click fix project properties.
4. The leak window error occurs.
Cause: every Activity in Android has a WindowManager form manager. Similarly, the dialog box and PopupWindow built on an Activity also have the corresponding WindowManager form manager. Because the Dialog box and popupdomainwn cannot be independent from the Activity, when a Dialog or PopupWindow is being displayed, we finish () the Activity that carries the Dialog (or PopupWindow, the Window Leaked exception will be thrown, because no one in the WindowManager of this Dialog (or PopupWindow) can attach it, so its form manager has been Leaked.
Solution: Before you finish an Activity, make sure that the attached Dialog or PopupWindow has been closed (dismiss.
@Override public void onPause(){ super.onPause(); if(pw != null) { pw.dismiss(); } }
Reference: http://blog.csdn.net/andy_android/article/details/7304761
5. display the line number in Eclipse
In the code writing area, right-click the border on the left and select Show Line Numbers to display the row number.
6. A java. lang. OutOfMemoryError: bitmap size exceeds VM budget error occurs when you use the setImageResource (int res id) method of ImageView.
Cause: the memory occupied by the image exceeds the maximum memory limit allocated by the system, resulting in memory overflow.
Solution: Use BitmapFactory's Options parameter to parse image resources, as shown in the Code:
BitmapFactoty.options opts = new BitmapFactory.Options();opts.inSampleSize = 4;Bitmap bitmap = BitmapFactory.decodeResource(Resources res, int id,opts);
Of course, when bitmap is not used, it should be forcibly recycled as follows:
if(bitmap != null && !bitmap.isRecycled()){bitmap.recycle();}
In addition, pay attention to code optimization. For example, Do not reinitialize variables, use local variables whenever possible, and use static, final, private, and other keywords whenever possible.
Updated on January 1, March 10
7. java. lang. IllegalStateException: The specified child already has a parent You must call removeView () on the child's parent first is unclear. read my blog post:
Http://blog.csdn.net/yaolingrui/article/details/7339913
8. When I configure the android development environment for 64-bit ubuntu (in fact, this often happens on 64-bit Linux), I am surprised: "failed to create the SD card. "and" failed to create sdcard In the AVD folder."
If this happens on a 64-bit machine, it may be because you have not installed a ia32-libs that supports 32-bit software. In this case,
You can enter $ sudo apt-Get install ia32-libs on the command line.
Specific reference: http://stackoverflow.com/questions/3878445/ubuntu-error-failed-to-create-the-sd-card
04.20 update 9. Generally, the R. java file in the Android Project is Automatically generated. Even if you manually delete the file, it is Automatically generated after you select Project-> Build Automatically. However, sometimes new resource files are found in the R. the corresponding id cannot be generated in the java file. if the java file is deleted, it will not be automatically generated, even if the build fails. At this time, the problem is probably caused by a problem with your resource files, such as the layout file write format is not standard, or there are uppercase letters when naming. 04.21 update Calling startActivity () from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag indicates that a new Activity is started outside the context of the Activity, in this case, you need to set the start mode of the new Activity to FLAG_ACTIVITY_NEW_TASK. The task is equivalent to the Activity container. The current Activity is at the top of the task, so that many activities are located in one task, different activities can also be located in different tasks. PracticeIntent intent = new Intent(getApplicationContext, Xxxx.class);intent.addFlags(Intent, FLAG_ACTIVITY_NEW_TASK);getApplicationContext.startActivity(intent);
11. Remove the horizontal line between items in the listview.
mListView.setDividerHeight(0);
12. Split in string
"Abcdsa. afac. casdf ". split (". "); // This is not acceptable." afda. aafa. cadsfd. ASD ". split ("\\. "); // you can do this.
In a regular expression, "." is a special character and must be escaped.