Android learning notes 03: some problems and solutions in the learning process

In the process of learning Android development encountered a lot of problems, fortunately, the final search through the Internet have been solved. Now some of the problems I encountered in the process of learning Android development and the solutions are sorted out as follows.
1.R.java cannot be updated in real time
Description of the problem: New variables in the res file are not displayed in real time in R.java.
Solution: Select “Project” from the menu bar and check the “Build Automatically” option.
2.LogCat window is not displayed
Problem description: The LogCat window is not displayed in the lower right corner of Eclipse.
Solution: Select “Windows” from the menu bar, then “Show View”, and finally “LogCat”.
“Android Library Projects Cannot Be Launched
“Android Library Projects Cannot Be Launched” error
Solution: Select “Project” in the menu bar, then “Properties”, select “Android” in the pop-up window, and uncheck the IS Library option.
4. “This text field does not specify an InputType or a hint” error after adding EditText control to XML
Problem description: Add EditText control to XML. Control information is as follows.
& lt; The EditText
android: id = “@ + id/EditText”
android: layout_width = “match_parent”
android: layout_height = “wrap_content” & gt; < /EditText>
Error “This text field does not specify an InputType or a hint” at compile time.
Control lacks android:hint and android:inputType information. The android:hint is used to set the default text prompt displayed when EditText is null. Android: InputType is used to set the text type of EditText, which is used to help the input method display the appropriate keyboard type.
Add android:hint and android:inputType information to the control. Add the control information as follows.
& lt; The EditText
android: id = “@ + id/EditText”
android: hint = “0”
android: inputType = “number”
android: layout_width = “match_parent
” Android: layout_height = “wrap_content” & gt; < /EditText>
5. Warning message “Hardcoded string” XXX “, should use @string resource
Problem description: Add Button control in XML, control information is as follows.
& lt; The Button
android: id = “@ + id/mButton_mc”
android: text = “MC”
android: layout_width = “match_parent
” android: layout_height = “wrap_content” & gt;
& lt; /Button>
At compile time, prompt “Hardcoded string” MC “, should use @string resource warning.
The String MC is used in Android :text. You should define the String in string.xml and then use the String resource by calling the String resource name in string.xml. The advantage of doing this is that it can be a complete change and is useful when supporting multiple languages.
Solution: res–> in the project directory; values–> The following is the information for adding the String MC to string.xml.
< resources>
& lt; string name=”mc”> mc< /string>
< /resources>
Then, in the XML that uses the Button control, you use the string by calling its resource name, as follows.
& lt; The Button
android: id = “@ + id/mButton_mc”
android: text = “@ string/MC”
android: layout_width = “match_parent
” android: layout_height = “wrap_content” & gt;
& lt; /Button>
6. Nested weights are bad for performance
Analysis: When using a nested layout, both parent and child layouts use android:layout_weight, but when it is not required, a warning appears as shown in the title.
Solution: Remove the android:layout_weight that is not required for the sublayout, depending on the situation.
7. The solution to an error message “Please ensure that ADB is correctly located at:XXXXX” when starting the emulator
Executed: When using the correct source code, the following error message “Please ensure that ADB is correctly located at ‘D:\AndroidSDK4.0\ Android-SDK-Windows \ Platform-tools \ Adb.exe ‘and can be executed.”
D:\AndroidSDK4.0\ Android-SDK-Windows-Platform-Tools = D:\AndroidSDK4.0\ Android-SDK-Windows-Platform-Tools = PATH
Waiting for HOME (‘ Android.process.acore ‘) to be launched… Waiting for HOME (‘ Android.process.acore ‘) to be launched… The solution to this problem
Phenomena: When the simulator starts, it cannot start after Waiting for a long time (more than 5 minutes). It keeps saying “Waiting for HOME (‘ Android.process.acore ‘) to be launched…”. Information.  
Solution: Delete the current emulator and create a new one.
9.Android emulator landscape screen and portrait screen toggle
After the emulator is started, select the emulator and press Ctrl +F11 to switch between landscape and portrait screen of the Android emulator.
10. The imported Android project @Override returns an error
Phenology: When importing the Android project source code downloaded from the Internet into Eclipse, @Override returns an error.
On the project that reported the error, right-click on Properties–>; Java Compiler–> Select 1.6 in Compiler Compliance Level to refresh the project, and the error will not be reported.
 

Read More: