您好,欢迎光临本网站![请登录][注册会员]  
文件名称: android 省市二级联动数据
  所属分类: Android
  开发工具:
  文件大小: 14kb
  下载次数: 0
  上传时间: 2014-11-13
  提 供 者: ysn***
 详细说明: spProvince = (Spinner)findViewById(R.id.spAddMettingAddressProvince); spCity = (Spinner)findViewById(R.id.spAddMettingAddressCity); ArrayAdapter aAdapter = ArrayAdapter.createFromResource(this, R.array.province, android.R.layout.simple_spinner_item); aAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spProvince.setAdapter(aAdapter); spProvince.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { Spinner spinner = (Spinner)parent; String pro = (String)spinner.getItemAtPosition(position); ArrayAdapter cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.city_default, android.R.layout.simple_spinner_item); //new ArrayAdapter // (MainActivity.this,android.R.layout.simple_spinner_item, cities); //获取所在省含有哪些市(从资源数组文件中获取数据) if(pro.equals("河北省")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.hebei, android.R.layout.simple_spinner_item); }else if(pro.equals("北京市")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.bj, android.R.layout.simple_spinner_item); }else if(pro.equals("山西省")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.shan1xi, android.R.layout.simple_spinner_item); }else if(pro.equals("天津市")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.tianjing, android.R.layout.simple_spinner_item); }else if(pro.equals("内蒙古")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.neimeng, android.R.layout.simple_spinner_item); }else if(pro.equals("辽宁省")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.liaoning, android.R.layout.simple_spinner_item); }else if(pro.equals("吉林省")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.jilin, android.R.layout.simple_spinner_item); }else if(pro.equals("黑龙江省")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.heilongjjiang, android.R.layout.simple_spinner_item); }else if(pro.equals("上海市")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.shanghai, android.R.layout.simple_spinner_item); }else if(pro.equals("江苏省")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.jiangsu, android.R.layout.simple_spinner_item); }else if(pro.equals("浙江省")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.zhejiang, android.R.layout.simple_spinner_item); }else if(pro.equals("安徽省")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.anhui, android.R.layout.simple_spinner_item); }else if(pro.equals("福建省")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.fujian, android.R.layout.simple_spinner_item); }else if(pro.equals("江西省")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.jiangxi, android.R.layout.simple_spinner_item); }else if(pro.equals("山东省")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.shandong, android.R.layout.simple_spinner_item); }else if(pro.equals("河南省")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.henan, android.R.layout.simple_spinner_item); }else if(pro.equals("湖北省")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.hubei, android.R.layout.simple_spinner_item); }else if(pro.equals("湖南省")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.hunan, android.R.layout.simple_spinner_item); }else if(pro.equals("广东省")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.guangdong, android.R.layout.simple_spinner_item); }else if(pro.equals("广西自治区")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.guangxi, android.R.layout.simple_spinner_item); }else if(pro.equals("海南省")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.hainan, android.R.layout.simple_spinner_item); }else if(pro.equals("重庆市")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.chongqing, android.R.layout.simple_spinner_item); }else if(pro.equals("四川省")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.sichuan, android.R.layout.simple_spinner_item); }else if(pro.equals("贵州省")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.guzhou, android.R.layout.simple_spinner_item); }else if(pro.equals("云南省")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.yunan, android.R.layout.simple_spinner_item); }else if(pro.equals("西藏自治区")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.xizang, android.R.layout.simple_spinner_item); }else if(pro.equals("陕西省")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.shan3xi, android.R.layout.simple_spinner_item); }else if(pro.equals("甘肃省")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.gansu, android.R.layout.simple_spinner_item); }else if(pro.equals("青海省")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.qinghai, android.R.layout.simple_spinner_item); }else if(pro.equals("宁夏回族自治区")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.ningxia, android.R.layout.simple_spinner_item); }else if(pro.equals("新疆维吾尔自治区")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.xinjiang, android.R.layout.simple_spinner_item); }else if(pro.equals("香港特别行政区")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.xianggang, android.R.layout.simple_spinner_item); }else if(pro.equals("澳门特别行政区")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.aomen, android.R.layout.simple_spinner_item); }else if(pro.equals("台湾省")){ cityAdapter = ArrayAdapter.createFromResource (MettingAddActivity.this, R.array.taiwan, android.R.layout.simple_spinner_item); } cityAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); //绑定数据到Spinner(City)上 spCity.setAdapter(cityAdapter); } @Override public void onNothingSelected(AdapterView parent) { } }); ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 输入关键字,在本站1000多万海量源码库中尽情搜索: