Android Basic Learning | Weekly Summary

Words written in the front

1. It has been more than a week since the beginning of learning, so the summary is also a review of the knowledge learned during this time.
2. Similarly, if there are any shortcomings, I hope I can point out or add them.

1. Some tips learned

1. Set the language of the virtual device (mobile phone)

Because the language of the virtual phone is English by default, if you want to change the language, you can do this:找到虚拟设备上的Settings图标并点击→Language & input→Language→选择你想要的语言

2. Shortcut keys

With shortcut keys, it will be helpful when writing code.

① Commonly used shortcut keys: I usually use ctrl+/ to comment the current line of code.
Insert picture description here
② Custom shortcut keys:在Android Studio菜单中点击【File】➡【Settings…】选项➡选择【Keymap】➡在出现的对应界面,空白处右击

3. DDMS tools

① Open method (Android Studio4.1.1 version): Find the monitor.bat file in the "D:\AndroidSDK\tools" directory, and double-click it.

② Operation: screenshot function (click the camera icon); view the files saved in the database (data----data----find the project you built, db end).

4. The effect of changing the default letters in all capitals

Add in the corresponding layout code: android:textAllCaps="false"

5. About the project name

① Change the project name (displayed above the virtual machine): Find the app_name of strings.xml in the values ​​folder and change it.

② The project name is not displayed: modify the content of the parent part of the themes.xml (theme) file (see below).
Insert picture description here
6. Find bugs

The way to find bugs is to find the beginning of caused by, from bottom to top. Pay attention to details and test more.

2. About the layout

After learning the basic knowledge of Android and some basic operations of Android Studio through the first Android application (Hello Word), I started learning about layout. Among them (linear layout, frame layout, relative layout, grid layout) I focused on learning linear layout and relative layout.

Let me briefly talk about the characteristics of FrameLayout and GridLayout : the former is a 层叠样式layout (that is, one layer is wrapped with one layer. It should be noted that the controls added later will be stacked to those added first. Above); the latter is equivalent to a 划分行数和列数grid layout, you need to define the values ​​of columnCount (total number of columns) and rowCount (total number of rows), and then use layout_row (row) and layout_column ( The value of column) defines the position (for example, layout_row="0" and layout_column="0" indicate the grid position of the first row and first column).

① Linear layout (LinearLayout)

Features: When the controls are arranged horizontally, the display order is from left to right, and each child element occupies one column; when the controls are arranged vertically, the display order is from top to bottom, and each child element occupies a row. Support layout style nesting.

Attribute: The weight attribute (layout_weight) is a unique attribute of linear layout. The corresponding properties are also tested.

Attributes effect value
android:orientation Set the arrangement direction of the internal components of the linear layout manager horizontal (default), vertical
android:layout_weight Used to specify the ratio of the remaining free space (allocate the remaining space of the current parent container according to the given ratio) Value

② Relative Layout (RelativeLayout)

Features: The most flexible, the position of a control depends on the relative relationship between itself and other controls. The position relative to the sibling control must be specified by ID.

Attributes: learned and tested the corresponding attributes.

Relative to Attributes effect value
Parent container
android:layout_alignParentBottom
Down
true or false
android:layout_centerInParent
Vertically and horizontally centered
android:layout_centerHorizontal
Center horizontally
Brother controls
android:layout_toLeftOf
On the left of the control
The id of the sibling control
android:layout_above
On the control
android:layout_alignBottom
Bottom aligned

Three, about the control

In terms of controls, I learned a lot about the RecyclerView (RecyclerView). The functions including ListView with horizontal scrolling, GridView with horizontal scrolling, and waterfall flow control are completed, as follows.
Insert picture description here

Four, about event handling

Learn to handle keyboard events and touch events (the listener is View.OnTouchListener, and the event processing method is onTouch()).

The keyboard events include click events (the listener is View.OnClickListener, the event processing method is onClick()), focus events (the listener is View.OnFocusChangeListener, and the event processing method is onFocusChange()), key events (the listener is View.OnKeyListener, the event handling method is onKey()).

Corresponding tests have also been done to get familiar with them.

Five, about the practice task

The following tasks have been completed so far.

1. Interface exercises

When making the interface layout, there must be a clear plan (design idea) to better complete the interface layout.

① Log in
Insert picture description here
② Home page 1
Insert picture description here
③ Home page 2
Insert picture description here
④ Relative layout
Insert picture description here
⑤ List exercise
Insert picture description here
2. Log in and register

This part mainly involves page jump and click events. To achieve the jump, you need to make an activity declaration in the project manifest (AndroidManifest.xml) file.
Insert picture description here
3. Contact management

Because I was not familiar with the operation of Ormlite at the beginning, in order to be familiar, this part took the most time (compared to several other tasks).
Insert picture description here
4. Summary

When doing these tasks, I have basically had a hot spot (code error) in every one of them. Often an error will cost me several hours of energy consumption. In these situations, I have also learned that there is a process of thinking. The importance of and the importance of being careful, because my error is basically derived from the details of my code misspelling a word or quoting another id. There are still some tasks that are not handled very well and need to be improved later.

Guess you like

Origin blog.csdn.net/luck_ch09/article/details/112801160