Android UI控制元件之Spinner實現省市區三級聯動
阿新 • • 發佈:2019-02-01
城市資訊我將他放在strings.xml檔案中,具體就不給出了,資訊太大了
主xml檔案如下:
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
-
android:focusableInTouchMode="false" >
- <TableLayout
- android:id="@+id/tableLayout1"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:paddingTop="20px"
- android:stretchColumns="1" >
- <TableRow
- android:id="@+id/tableRow1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
-
android:paddingTop=
- android:scrollbarAlwaysDrawVerticalTrack="false" >
- <TextView
- android:id="@+id/province_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="省份:" >
- </TextView>
- <Spinner
- android:id="@+id/province_spinner"
-
android:layout_width="wrap_content"
- android:layout_height="wrap_content" >
- </Spinner>
- </TableRow>
- <TableRow
- android:id="@+id/tableRow2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingTop="10px"
- android:scrollbarAlwaysDrawVerticalTrack="false" >
- <TextView
- android:id="@+id/city_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="城市:" >
- </TextView>
- <Spinner
- android:id="@+id/city_spinner"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" >
- </Spinner>
- </TableRow>
- <TableRow
- android:id="@+id/tableRow3"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingTop="10px"
- android:scrollbarAlwaysDrawVerticalTrack="false" >
- <TextView
- android:id="@+id/county_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="縣城鎮:" >
- </TextView>
- <Spinner
- android:id="@+id/county_spinner"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" >
- </Spinner>
- </TableRow>
- <EditText
- android:id="@+id/display_edit"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:focusableInTouchMode="false"
- android:hint="輸出結果"
- android:paddingTop="10px" >
- </EditText>
- </TableLayout>
- </RelativeLayout>
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:focusableInTouchMode="false" >
- <TableLayout
- android:id="@+id/tableLayout1"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:paddingTop="20px"
- android:stretchColumns="1" >
- <TableRow
- android:id="@+id/tableRow1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingTop="10px"
- android:scrollbarAlwaysDrawVerticalTrack="false" >
- <TextView
- android:id="@+id/province_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="省份:" >
- </TextView>
- <Spinner
- android:id="@+id/province_spinner"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" >
- </Spinner>
- </TableRow>
- <TableRow
- android:id="@+id/tableRow2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingTop="10px"
- android:scrollbarAlwaysDrawVerticalTrack="false" >
- <TextView
- android:id="@+id/city_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="城市:" >
- </TextView>
- <Spinner
- android:id="@+id/city_spinner"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" >
- </Spinner>
- </TableRow>
- <TableRow
- android:id="@+id/tableRow3"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingTop="10px"
- android:scrollbarAlwaysDrawVerticalTrack="false" >