In summary:What is the communication mechanism between multiple different activity in an application, and between multiple different instances of an activity?
There are usually four kinds:
Intent is used for message passing between components, and can span processes and threads. But cross-processes need to be bundled with other mechanisms (such as binder).
(Note: Thebinder mechanism is the architecture of interprocess communication implemented in Android )
Handle is typically used for updates to the main thread (UI thread) interface, which is implemented through a messaging mechanism. (need to use looper). This mechanism is typically used for thread communication.
Broadcast general and intent together, mainly for inter-process communication more.
Service is used in conjunction with intent and can be bound or unbound for interprocess communication.
?
?
Synchronization between Threads:
Synchronizing code blocks, synchronizing methods
In fact, there are some API to control the order of execution, with the lock, the simple is to let who first plug, let who first execute.
?
?
- Warning dialog box usage
Note: Setcancelable can be canceled for the back button.
- Progress bar Usage
To set properties:
- Usage of weights
Sometimes this is used, so the button is set to Wrap_content,edittext to fill the rest of the screen
- Relative layout
In a relative layout, all properties are relative to the parent control or the parent control. This needs to be clear.
And in the layout file, all the control declarations are in order. For example, the button1 above Button3 can be referenced without declaring button3. This is wrong.
?
Three sets of attributes:
- Relative to Parent layout:
Layout_alignparentleft layout_alignparentright and top bottom missing layout_centerinparent
2) relative to the control
Layout_above below Toleftof torightof et cetera
?
There is also a property that is positioned relative to the control: Layout_alignleft, and so on.
- Tablelayout
You cannot specify a width for a control in this layout, we can merge cells for each row, property Layout_span
<tablerow > Represents a row. Each control represents a column.
There is also an important attribute that is used for adaptation, and Android:stretchcolumns=1 represents stretching the second column. 0 means that the first column is stretched.
- Custom controls
Build Title_layout, and then we can put this control into other controls. As shown in the following:
Only need to add code: <include layout= "@layout/title_layout"/>
Of course, the system comes with a title bar that we need to hide out. Auto-hide in as. In eclipse, the attribute needs to be added: Requestwindowfeature (window.feature_no_title);
?
?
Of course we can also add a custom control in another way:
Build the Layoutinflater object through the Layoutinflate from () method, then call inflate to load a layout file, the parameter loads the layout file we want to add, and the second one adds a parent layout to the loaded layout file.
Here we pass in this. Represents the specified titlelayout.
The same as the result of the above operation.
Of course, we can also add key processing methods for custom controls, which is more flexible than include, which is used more in real development.
?
- Use of the ListView
- Writing entity classes
- Writing the list subkey Layout menu
- Write the adapter for the ListView
Some of the following are optimized code:
- Add an adapter to the ListView
?
Note: In the above steps, some resources need to be added themselves, such as in this example, the added resources have some pictures as follows:
- Layout and Text size designation
Android rules 160dpi (screen density) in this 1DP = 1px. PX represents pixels. The DP can also be written as DPI, which indicates that the density is pixel independent. The SP is similar to DP.
Remember: DP generally specifies the size of the control and layout. The SP specifies the size of the text.
- Making Nine-patch Pictures
This is an artifact that allows you to specify which parts of a. png image can be stretched and which cannot be stretched. This application is in the SDK---tool----draw9patch.bat.
The file is named Message_left.9.png, but when we specify it in XML, it is Message_left, followed by his extension.
- Case: Making a chat window
Steps: Main_layout/msg_layout, entity class, adapter class, Mount adapter
See procedure for detailed steps.
?
The first line of code reading notes the common error analysis