Android快速SDK(10)地址库Location【傻瓜模式】
2015-11-10 20:01
519 查看
代码:http://download.csdn.net/detail/huangbin95487710/9258865
依赖包模式
完整运行还需要用到以下依赖包
Android快速SDK(2)View库QuickView
Android快速SDK(3)数据库Sqlite
属性配置,一般使用默认配置即可支持更改背景颜色
支持更改字体大小,左右间距,可见速度
支持更改每行的高度与间距
支持城市,省份,区域组合显示
<declare-styleable name="LocationView"> <!-- 精确度 --> <attr name="location_accuracy"> <enum name="province" value="0" /> <enum name="city" value="1" /> <enum name="district" value="2" /> </attr> <!-- item文字颜色 --> <attr name="location_value_text_color" format="color" /> <!-- item选中文字颜色 --> <attr name="location_items_text_color" format="color" /> <!-- 背景颜色 --> <attr name="location_background_color" format="color" /> <!-- 字体大小 --> <attr name="location_text_size" format="dimension" /> <!-- 左右间距 --> <attr name="location_padding" format="dimension" /> <!-- 可见数量 --> <attr name="location_visible_items" format="integer" /> <!-- 滚动速度 --> <attr name="location_scrolling_duration" format="integer" /> <!-- item高度 --> <attr name="location_additional_item_height" format="dimension" /> <!-- item间距 --> <attr name="location_additional_items_space" format="dimension" /> <attr name="android:layout_width" /> <attr name="android:layout_height" /> </declare-styleable>
默认样式
<style name="DivLocationView"> <item name="location_accuracy">district</item> <item name="location_value_text_color">@color/location_def_value_text_color</item> <item name="location_items_text_color">@color/location_def_items_text_color</item> <item name="location_background_color">@color/location_def_background_color</item> <item name="location_text_size">@dimen/location_def_text_size</item> <item name="location_padding">@dimen/location_def_padding</item> <item name="location_visible_items">@integer/location_def_visible_items</item> <item name="location_scrolling_duration">@integer/location_def_scrolling_duration</item> </style>
代码示例
布局XML
<RelativeLayout android:id="@+id/picker_layout" android:layout_width="match_parent" android:layout_height="fill_parent" android:layout_alignParentBottom="true" > <General.Location.LoactionView.LocationView android:id="@+id/location" style="@style/MyDivLocationView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginTop="25dp" /> </RelativeLayout>
代码
package cn.whonow.whonow.loc; import General.Location.DB.LocService; import General.Location.LoactionView.LocationDto; import General.Location.LoactionView.LocationView; import General.Location.LoactionView.onLocationChangeListener; import General.System.MyLog; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import cn.whonow.whonow.R; /** 必须实现onLocationChangeListener接口 */ public class LocActivity extends Activity implements onLocationChangeListener { private LocService mLocService; private LocationView mLocation; private LocationDto mDto; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.test_loc); mLocService = new LocService(this); mLocation = (LocationView) findViewById(R.id.location); mLocation.setOnLoactionChangeListener(this); mLocation.setVisibility(View.INVISIBLE); Button mButtonTxt = (Button) findViewById(R.id.button1); mButtonTxt.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // 获取默认列表信息 MyLog.show(LocActivity.this, "省份列表:" + mLocService.getDefaultProvince().size() + " 默认城市列表:" + mLocService.getDefaultCity().size() + " 默认区县列表:" + mLocService.getDefaultDistrict().size()); } }); Button mButton2 = (Button) findViewById(R.id.button2); mButton2.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // 显示选择列表 mLocation.setVisibility(View.VISIBLE); } }); Button mButton3 = (Button) findViewById(R.id.button3); mButton3.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // 隐藏选择列表 mLocation.setVisibility(View.INVISIBLE); MyLog.show(LocActivity.this, "省份:" + mDto.provinceName + " 城市:" + mDto.cityName + " 区县:" + mDto.districtName); } }); } @Override public void onLocationChange(LocationDto base) { // TODO Auto-generated method stub mDto = base; } }
效果图
相关文章推荐
- Android点滴(一)
- Android快速SDK(9)下载库DownLoad【傻瓜模式】
- A-1 Android简介
- android杂项记录
- android两种方式生成keystore
- Android中常用的位图操作(View与Bitmap转化、圆角、灰化、提取Alpha、旋转、倒影、剪切……)
- MTK Android G-Sensor auto detect源码分析
- Android快速SDK(8)毛玻璃效果BlurView【傻瓜模式】
- Android中图片的二次采样示例
- Android快速SDK(7)图像加载库ImageLoader【傻瓜模式】
- AndroidStudio快速入门二:Gradle快速构建Android项目(多个Module同时构建)
- Android AIDL使用详解 实现进程间的通信
- Android开发 关于百度地图的定位
- 分享:Android Studio 导入第三方jar包,重复加载错误解决办法。
- android中aidl的简单使用
- Android快速SDK(6)本地图形库CopyView
- android自定义View控件,实现自定义进度条控件
- ScrollView中listview显示不全的问题
- Android打包APK遇到的错误]conversion to dalvik format failed with error 1的解决办法
- android优化图片内存