Bài 18: Cập nhật DataSource cho AutocompleteTextView lúc Runtime (P1)

Leave a Comment
1- Đây là cấu trúc thư mục trong ứng dụng:
18_auto_3
-Nhìn vào cấu trúc thì bạn thấy có 2 Layout, layout chính là activity_main.xml,  còn layout sinhvien_item_layout.xml là Tôi dùng để custom lại ListView (nó sẽ được xử lý trong classMyArrayAdapter).
2- Thiết kế giao diện với màn hình nằm ngang (xem hình):
18_auto_1
- Dưới đây là Outline activity_main.xml:
18_auto_2- Nếu như nhìn vào Outline mà bạn có thể thiết kế được giao diện như trên thì Tôi nghĩ bạn đã thật sự hiểu về Layout, tuy nhiên Tôi vẫn cung cấp Source XML, bạn xem tham khảo

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/LinearLayout1"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 tools:context=".MainActivity" >
<LinearLayout
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:background="#FFF0E1"
 android:orientation="vertical" >
<TextView
 android:id="@+id/textView1"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:background="#008000"
 android:text="Nhập Thông Tin Sinh Viên:"
 android:textColor="#FFFFFF" />
<TableLayout
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 >
<TableRow
 android:id="@+id/tableRow2"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content" >
<TextView
 android:id="@+id/textView3"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="Mã:" />
<EditText
 android:id="@+id/editMa"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_span="2" >
<requestFocus />
 </EditText>
</TableRow>
<TableRow
 android:id="@+id/tableRow3"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content" >
<TextView
 android:id="@+id/textView4"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="Tên:" />
<EditText
 android:id="@+id/editTen"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_span="2" />
</TableRow>
<TableRow
 android:id="@+id/tableRow4"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content" >
<TextView
 android:id="@+id/textView5"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="Giới tính:" />
<CheckBox
 android:id="@+id/chkGt"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_span="2"
 android:text="Là Nữ" />
</TableRow>
<TableRow
 android:id="@+id/tableRow5"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content" >
<TextView
 android:id="@+id/textView6"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="Ngày sinh:" />
<EditText
 android:id="@+id/editNgaySinh"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:inputType="date"
 android:text="25/09/1989" />
<Button
 android:id="@+id/btnNgaySinh"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="..." />
</TableRow>
<TableRow
 android:id="@+id/tableRow6"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content" >
<TextView
 android:id="@+id/textView7"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="Nơi sinh:" />
<AutoCompleteTextView
 android:id="@+id/autoCompleteNS"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:completionThreshold="1"
 android:layout_span="2"
 android:ems="10" />
</TableRow>
<TableRow
 android:id="@+id/tableRow7"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content" >
<Button
 android:id="@+id/btnNhap"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_column="1"
 android:gravity="center"
 android:text="Nhập SV" />
</TableRow>
</TableLayout>
 </LinearLayout>
<LinearLayout
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_weight="1"
 android:background="#EAEAEA"
 android:orientation="vertical" >
<TextView
 android:id="@+id/textView2"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:background="#000040"
 android:text="Danh Sách Sinh Viên:"
 android:textColor="#FFFFFF" />
<ListView
 android:id="@+id/lvsinhvien"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:layout_weight="1" >
 </ListView>
</LinearLayout>
</LinearLayout>
Xem tiếp P2...

0 nhận xét:

Đăng nhận xét