Android快速SDK(10)地址库Location【傻瓜模式】
来源:互联网 发布:idc联想数据 编辑:程序博客网 时间:2024/06/06 01:59
代码: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;@Overrideprotected 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() {@Overridepublic 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() {@Overridepublic void onClick(View v) {// 显示选择列表mLocation.setVisibility(View.VISIBLE);}});Button mButton3 = (Button) findViewById(R.id.button3);mButton3.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {// 隐藏选择列表mLocation.setVisibility(View.INVISIBLE);MyLog.show(LocActivity.this, "省份:" + mDto.provinceName + " 城市:"+ mDto.cityName + " 区县:" + mDto.districtName);}});}@Overridepublic void onLocationChange(LocationDto base) {// TODO Auto-generated method stubmDto = base;}}- 效果图
0 0
- Android快速SDK(10)地址库Location【傻瓜模式】
- Android快速SDK(9)下载库DownLoad【傻瓜模式】
- Android快速SDK(8)毛玻璃效果BlurView【傻瓜模式】
- Android快速SDK(15)二维码扫描Scanner【傻瓜模式】
- Android快速SDK(16)摇一摇Shake【傻瓜模式】
- Android快速SDK(18)Tab页面TabPager【傻瓜模式】
- Android快速SDK(7)图像加载库ImageLoader【傻瓜模式】
- Android快速SDK(11)圆弧菜单库PathView【傻瓜模式】
- Android快速SDK(13)拍照裁剪库PhotoGraph【傻瓜模式】
- Android快速SDK(19)录音播放库SoundRecorder【傻瓜模式】
- Android快速SDK(12)文本pdf阅读器PdfViewer【傻瓜模式】
- Android快速SDK(17)左右滑动菜单SlidingMenu【傻瓜模式】
- Android快速SDK(20)视频播放器VideoPlayerE【傻瓜模式】
- Android快速SDK(1)基础工具库QuickBase
- Android快速SDK(2)View库QuickView
- Android快速SDK(5)联网请求库QuickHttp
- Android快速SDK(6)本地图形库CopyView
- Android快速SDK(25)动画库Animation
- leetcode-Symmetric Tree
- lib与dll文件的区别与联系
- Range Sum Query - Immutable
- 深入浅出Android Support Annotation(什么是android.support.annotation.NonNull的拓展)【转】
- Hibernate 面试总结
- Android快速SDK(10)地址库Location【傻瓜模式】
- sicily 10625 TRENER
- ubuntu下把微信的amr音频格式转换为 mp3格式
- ZOJ 1563 Pearls(一个物品和他之前的组合情况)
- git删除文件所有历史版本
- 工欲善其事,必先利其器--phper的sublime text3
- ERP见面会
- 静态Static(C#)
- leetcode 48:Rotate Image