Android development and design learning, Android Development and Design
3. Common UI Layout
1). LinearLayout: Linear Layout
Used to control the display of its subviews in horizontal or vertical mode.
2). RelativeLayout: relative Layout
Used to control its subviews for layout display in relative positioning Mode
3). FrameLayout: frame Layout
Each sub-View represents a screen, and the subsequent View will overwrite the previous screen.
The android: layout_gravity attribute of the sub-View is used to indicate the position of the sub-View.
4. Attributes of common view labels
1). Common view attributes
2). Only for RelativeLayout
3). Only for LinearLayout
5. Use of ListView
1). Understanding
2). Use
A. ArrayAdapter: displays the simple text list.
B. SimpleAdpater: display the complex list
C. BaseAdpater (abstract): displays a complex list
Int getCount (): obtains the number of data sets and determines how many rows can be displayed.
Object getItem (int position): obtains the corresponding data Object based on position.
View getView (int position, View convertView, ViewGroup parent)
// Return the corresponding Item view object with data according to position
Position: subscript
ConvertView: Reusable Item view object
Null: No reusable items. We must load an item layout file and assign it to convertView.
Not null: directly use this view object
Next: Find the sub-View, find the corresponding data, and set the data
Parent: ListView
D. Set a listener for the ListView Item
Item click listening: listView. setOnItemClickListener (listener)
Item long-pressed listener: listView. setOnItemLongClickListener (listener)
3). Optimization
A. a maximum of n + convertView objects exist in the memory.
B. The layout file of the item is loaded only when convertView is null.
6. style and Theme
1). style: a set of multiple view label attributes
Benefit: Reuse tag attributes
Objective: To view labels in the layout File
2). theme: The essence is also style.
Benefit: Reuse tag attributes
Objective: To view the entire application/Activity in the function list file