Android Study Notes 03: problems encountered during the learning process and Solutions

Source: Internet
Author: User

I encountered a lot of problems in the process of learning Android development. Fortunately, I finally got the solution through online queries. Now, I want to sort out some of the problems I encountered during the android development process and the solutions as follows.

1. R. Java cannot be updated in real time

Problem description: The new variables in the res file cannot be displayed in R. Java in real time.

Solution: select "project" in the menu bar and check the "build automatically" option.

2. The logcat window is not displayed.

Problem description: The logcat window is not displayed at the bottom right of Eclipse.

Solution: select "Windows" in the menu bar, select "show View", and then select "logcat.

3. Solution to the error "android library projects cannot be launched" prompt during compilation

Problem description: The error "android library projects cannot be launched" is prompted during compilation.

Solution: select "project" in the menu bar, and then select "properties". In the displayed window, select "android" to remove the check box before the is library option.

4. After the edittext control is added to the XML file, the message "this text field does not specify an inputtype or a hint" is returned.

Problem description: add the edittext control to XML. The control information is as follows.

<Edittext
Android: Id = "@ + ID/edittext"
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"> </edittext>

During compilation, the message "this text field does not specify an inputtype or a hint" is returned.

Cause Analysis: Android: hint and Android: inputtype are missing in the control.Android: hint is used to set the default text prompt information displayed when edittext is null.Android: inputtype is used to set the text type of edittext. It is used to help the input method display the appropriate keyboard type.

Solution: Add Android: hint and Android: inputtype information to the control. The added control information is as follows.

<Edittext
Android: Id = "@ + ID/edittext"
Android: hint = "0"
Android: inputtype = "Number"
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"> </edittext>

5. How to eliminate the warning message "hardcoded string" XXX ", shocould use @ string resource"

Problem description: Add a button control in XML. The control information is as follows.

<Button
Android: Id = "@ + ID/mbutton_mc"
Android: text = "MC"
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content">
</Button>

During compilation, the warning "hardcoded string" MC ", shocould use @ string resource" is displayed.

Cause analysis: the string MC is used in Android: text. The string should be defined in string. XML, and then call string. the Resource Name of the string in XML to use the string resource. The advantage of this solution is that it can be completely changed, and it is also useful in supporting multiple languages.

Solution: Add the following information to RES> values> string. XML in the project directory.

<Resources>
<String name = "MC"> Mc </string>

</Resources>

Then, in the XML using the button control, use the string by calling the Resource Name of the string, as shown below.

<Button
Android: Id = "@ + ID/mbutton_mc"
Android: text = "@ string/MC"
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content">
</Button>

6. How to eliminate the warning message "nested weights are bad for performance"

Cause Analysis: When the layout is nested, Android: layout_weight is used for both the parent layout and sub-layout, but the warning information shown in the figure is displayed if it is not required.

Solution: Remove unnecessary Android: layout_weight in the sub-layout based on the actual situation.

7. Solution to the error message "please ensure that ADB is correctly located at: XXXXX" when starting the simulator

Symptom: Correct UseSource codeWhen the simulator is started, 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."

Solution: Add D: \ androidsdk4.0 \ Android-SDK-Windows \ platform-tools to the system environment variable path.

8. The solution of "waiting for home ('android. process. acore') to be launched..." is always displayed when the simulator is started.

Symptom: When the simulator is started, it cannot be started for a long time (more than five minutes) and the system always prompts "waiting for home ('android. process. acore') to be launched... "Information.

Solution: Delete the current simulator and create a new simulator.

9. Horizontal and vertical screen switching of the android Simulator

After the simulator starts, select the simulator and press Ctrl + F11 to switch between the horizontal screen and portrait screen of the android simulator.

10. The imported Android Project @ override reports an error.

Symptom: @ override reports an error when importing the downloaded Android project source code to eclipse.

Solution:On the project with the error reported, right-click and choose Properties--> Java compiler --> select 1.6 in Compiler compliance level to refresh the project, and no error will be reported.

 

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.