Basic Android Learning

Source: Internet
Author: User

1. specify: specify 2. Nested: Nested 3. Solution to the error message "Please ensure that adb is correctly located at: XXXXX" when starting the simulator: use the correct source code, when 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 appears. solution: Add D: \ AndroidSDK4.0 \ android-sdk-windows \ platform-tools to the system environment variable PATH. What should I do if the problem persists? Run The android console and output [16:18:26-] The connection to adb is down, and a severe error has occured. [16:18:26-] You must restart adb and Eclipse. [16:18:26-] Please ensure that adb is correctly located at 'd: \ java \ sdk \ platform-tools \ adb.exe 'and can be executed. solve the problem: Baidu and google all say that the task manager kill adb or restart adb server, but my task manager does not have adb. It is assumed that a program occupies the adb port. So we can find it by following this idea. Adb kill-serveradb start-server 5037 is the default port of adb to view the status of this port as follows (I used to know this, but I didn't think it was used, but I recorded it as tricky ): netstat-aon | findstr "5037" TCP 127.0.0.1: 5037 0.0.0.0: 0 LISTENING 6540 found that 6540 occupied port 5037. Continue to check task 6540 and find it wandoujia. tasklist | findstr "6540" wandoujia_daemon.exe 6540 Console 1 4,276 K can solve the problem. In the Task Manager killdrop wandoujia_daemon.exe, run the android program, OK. 4. abstract: summary, abstract 5. xml layout file is a common method for defining controls in android systems. The purpose and advantage of this method is to display Easy to see, the program code is separated from the graphic UI to facilitate the maintenance of the Code and the graphic UI. The xml layout file must be included in the res/layout directory, and the root node of each xml layout file can be any view label. When you specify an id for a tag in the xml file layout, use the following format: android: id = "@ + id/Tag Name" the id of each tag will generate the corresponding variable in the R class, and the tag name will be saved in the R file. To use an xml layout file, use setContentView in the oncreate method to load the specified xml layout file. The loading method is as follows: public void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. main);} 6. How to control the relative position of a control in the parent control? Layout_margin is provided in the Android system to control the margin of a control edge relative to the parent control. Android: layout_marginTop indicates the distance between a widget and its parent widget. Android: layout_marginLeft indicates the distance between a widget and Its left border. Android: layout_marginRight indicates the distance between a widget and Its right border. Android: layout_marginButtom indicates the distance between a widget and its parent widget. 7. How to control the relative position of content in a control? Padding is provided in the Android system to control the margin of content in a control relative to the edge of the control. Android: paddingTop indicates the distance between the content of a control and the top edge of the control. Android: paddingLeft indicates the distance between the content of a control and the left edge of the control. Android: paddingRight indicates the distance between the content of a control and the right edge of the control. Android: paddingButtom indicates the distance between the content of a control and the bottom of the control edge. 8. Differences between android: gravity and android: layout_gravity android: gravity is used to set the alignment of the View component, while android: layout_gravity is used to set the alignment of the Container component. For example, you can set android: gravity = "center" to center the text in EditText in the EditText component, and set android of EditText: layout_gravity = "right" to center the EditText component in LinearLayout. 9. Difference Between Padding and margin the meaning of padding filling refers to the distance between content and view edge in the view, similar to indent in the text, margin represents the distance between the left edge of the view and the left edge of the parent view. margin is generally used to describe the location relationship between controls, while padding generally describes the relationship between the control content and the position of the control. 10. Linear layout can be divided into horizontal and vertical la S. You can use android: orientation to define the direction. android: orientation = "horizontal" indicates the horizontal direction. android: orientation = "vertical" indicates the vertical direction. Android: layout_width indicates the width of the Control. android_layout_height indicates the height of the control. The attribute values include wrap_content, fill_parent, and match_parent. Wrap_content indicates filling the blank space of the parent control, and fill_parent indicates that the size is enough to show the content in the current control. match_parent and fill_parent are used in the same way. Android: layout_weight indicates the weight of the control, which describes the proportion of the control. All views have the layout_weight value. The default value is zero, indicating the size of the screen space to be displayed. If a value higher than zero is assigned, the free space in the parent view is split, the split size depends on the layout_weight value of each view and the ratio of the layout_weight value in the current screen layout to the layout_weight value in the screen layout of other views. 11. The child view in the frame layout is always drawn to the upper left corner of the screen. All views added to this layout are displayed in a stacked manner. The first view added to the Framework layout is displayed at the bottom layer, and the last view is placed at the top layer. The view on the top layer overwrites the view on the next layer. Therefore, the Framework layout is similar to the STACK layout. In the Framework layout, the following attributes are commonly used: android: top: Put the view to the top of the screen android: Buttom put the view to the low-end android of the screen: left: place the view to the Left of the screen. android: Right: place the view to the Right of the screen. android: Center_vertical: center the view vertically. android: Center_horizontal: center the view horizontally.

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.