android省市区三级联动案例:(三)布局文件

主页面:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <RelativeLayout
        android:id="@+id/ly_title"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginTop="5dp"
        android:background="@drawable/top_bg" >

        <TextView
            android:id="@+id/tv_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="地区选择"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="#ffffff" />
    </RelativeLayout>

     <!-- 省份-->
    <RelativeLayout
        android:id="@+id/ly_province"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_below="@+id/ly_title" >

        <TextView
            android:id="@+id/tvlabel_province"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="省份"
            android:textColor="#919199"
            android:layout_centerVertical="true"
            android:textSize="20sp" />
       <TextView
            android:id="@+id/tv_province"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@+id/tvlabel_province"
            android:layout_marginLeft="40dp"
            android:layout_marginRight="10dp"
            android:layout_centerHorizontal="true"
            android:hint="请选择省份"
            android:textColor="#919199"
            android:layout_centerVertical="true"
            android:textSize="20sp" />

        <ImageView
            android:id="@+id/iv_province"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_marginRight="5dp"
            android:layout_centerVertical="true"
            android:background="@drawable/right_btn_icon" />       

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_below="@+id/tv_province"
            android:layout_alignParentRight="true"
            android:background="@drawable/line" />
    </RelativeLayout>

     <!-- 城市-->
       <RelativeLayout
        android:id="@+id/ly_city"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_below="@+id/ly_province" >

        <TextView
            android:id="@+id/tvlabel_city"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="城市"
            android:textColor="#919199"
            android:layout_centerVertical="true"
            android:textSize="20sp" />
       <TextView
            android:id="@+id/tv_city"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@+id/tvlabel_city"
            android:layout_marginLeft="40dp"
            android:layout_marginRight="10dp"
            android:layout_centerHorizontal="true"
            android:hint="请选择城市"
            android:textColor="#919199"
            android:layout_centerVertical="true"
            android:textSize="20sp" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_marginRight="5dp"
            android:layout_centerVertical="true"
            android:background="@drawable/right_btn_icon" />       

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_below="@+id/tv_city"
            android:layout_alignParentRight="true"
            android:background="@drawable/line" />
    </RelativeLayout>

      <!-- 地区 -->
     <RelativeLayout
        android:id="@+id/ly_area"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_below="@+id/ly_city" >

        <TextView
            android:id="@+id/tvlabel_area"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="地区"
            android:textColor="#919199"
            android:layout_centerVertical="true"
            android:textSize="20sp" />
       <TextView
            android:id="@+id/tv_area"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@+id/tvlabel_area"
            android:layout_marginLeft="40dp"
            android:layout_marginRight="10dp"
            android:layout_centerHorizontal="true"
            android:hint="请选择地区"
            android:textColor="#919199"
            android:layout_centerVertical="true"
            android:textSize="20sp" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_marginRight="5dp"
            android:layout_centerVertical="true"
            android:background="@drawable/right_btn_icon" />       

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_below="@+id/tv_area"
            android:layout_alignParentRight="true"
            android:background="@drawable/line" />
    </RelativeLayout>      

        <Button
            android:id="@+id/btnSure"
            android:layout_width="120dp"
            android:layout_height="50dp"
            android:layout_below="@+id/ly_area"
            android:layout_marginTop="10dp"
            android:layout_centerHorizontal="true"
            android:text="确定"
            android:background="@drawable/btn_gb" />

</RelativeLayout>

地址名称

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <TextView
        android:id="@+id/tv_address_name"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:textSize="18sp"
        android:paddingLeft="20px"
        android:paddingTop="20px"
        android:paddingRight="20px"
        android:paddingBottom="20px"/>

</LinearLayout>
时间: 2024-07-31 06:31:59

android省市区三级联动案例:(三)布局文件的相关文章

android省市区三级联动案例:(三)主要功能实现

MainActivity.java package com.test.address; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import org.xmlpu

android省市区三级联动案例:(二)项目结构图

目录结构 城市数据address.xml文件 <?xml version="1.0" encoding="utf-8"?> <root name="中国"> <province name="北京市"> <city name="北京市" index="1"> <area name="东城区" index="

android省市区三级联动案例:(一)运行效果

Android省市区三级联动滚轮选择(真实项目中提取出来的组件)

最近项目要做一个,类似淘宝手机客户端的,选择收货地址的三级联动滚动选择组件,下面是它的大致界面截图: 在IOS中有个叫UIPickerView的选择器,并且在dataSource中定义了UIPickerView的数据源和定制内容,所以用只要熟悉它的基本用法,要实现这么个三级联动滑动选择是挺简单的. 言归正传,今天讨论的是在Android里面如何来实现这么个效果,那么如何实现呢??? 相信部分童鞋首先想到的是android.widget.DatePicker和android.widget.Time

WheelView实现省市区三级联动(数据库实现版本号附带完整SQL及数据)

近期在实现收货地址功能,用到了省市区三级联动效果,网上找到一般都是xml或json.数据源陈旧改动麻烦.改动了一下使用数据库方式实现了一下 数据源解决.因为数据量比較大通过初始化批量运行SQL的方式不合适,费时不说还easy出错,我採用的是在电脑上创建好数据库然后把数据库文件放到程序里边,通过以下这种方法能够把db文件复制到随意文件夹下.demo中我把文件放在了raw文件夹下 /** * * @param inStream * @param fileNme 文件名称 * @param newPa

Ajax来实现下拉框省市区三级联动效果(服务端基于express)

//服务端JS代码: //提供服务端的处理 const express = require('express'); const fs = require('fs'); const app = express(); //载入选择城市的页面 app.get('/',function(req,res){ res.sendFile( __dirname + "/7.city.html" ); }); //获取所有的省份 app.get('/province',function(req,res)

jQuery简单的省市区县三级联动案例

简单的省市区三级联动,适合初学者入门学习的案例 目录结构如下: 三级联动.html 跟 JS文件夹是同个级别 效果图如下: HTML代码: 1 <style type="text/css"> 2 *{margin:0;padding:0;} 3 .selectAll 4 { width:400px; 5 margin:100px auto; 6 } 7 </style> 8 9 <div class="selectAll"> 10

用jQuery实现省市区三级联动(可做插件)

用jQuery实现省市区三级联动(可做插件) 有参考别的文档,如有雷同,不胜感激 先上效果图 上三级联动代码 city.html <!DOCTYPE html> <html> <head> <title>city.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http

收货地址--实现省市区三级联动和使用drf-extensions扩展使用缓存

主要实现省市区三级联动和在Django REST framework中使用缓存. 在用户录入地址时,需要进行省市区的选择.在页面加载时,向后端请求省份数据,当用户选择确定省份后,向后端请求该省份的城市数据:在用户选择确定城市数据后,向后端请求该城市的区县信息.我们把这个过程称为省市区三级联动. 我们新建一个应用areas来实现省市区三级联动. 1)终端:cd meiduo_mall/meiduo_mall/apps 2)创建areas子应用:python ../../manage.py star