(android地图开发) 高德地图自定义对话框
2013-08-15 17:03
666 查看
截图效果:
布局文件:
自定义对话框覆写Activity的oncreatDialog()方法------核心代码
MapView浮点按钮功能实现:
运行截图:
布局文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" android:background="#ffffff" > <!--卫星地图 --> <ImageButton android:id="@+id/satellite" android:layout_weight="1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/main_map_mode_satellite_normal" > </ImageButton> <!--平面地图 --> <ImageButton android:id="@+id/plain" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/main_map_mode_plain_normal" /> <!--3d地图 --> <ImageButton android:id="@+id/d3" android:layout_weight="1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/main_map_mode_3d_normal" > </ImageButton> </LinearLayout>
自定义对话框覆写Activity的oncreatDialog()方法------核心代码
//自定义窗口(覆写 activity的oncreatedialog()) @Override public Dialog onCreateDialog(int id) { // TODO Auto-generated method stub AlertDialog.Builder builder =new AlertDialog.Builder(this); final AlertDialog customDialog; LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.dialog, null); builder.setTitle("地图类型选择"); builder.setView(layout); customDialog=builder.create(); //相关点击事件处理 //卫星地图 ImageButton satellite=(ImageButton) layout.findViewById(R.id.satellite); satellite.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { // TODO Auto-generated method stub tager_map_type=0; Message message=new Message(); Bundle bundle=new Bundle(); bundle.putInt("target_map_type", tager_map_type); message.setData(bundle); message.what=2; handler.sendMessage(message); //自定义对话框关闭 customDialog.cancel(); } }); //平面地图 ImageButton plain=(ImageButton) layout.findViewById(R.id.plain); plain.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { // TODO Auto-generated method stub tager_map_type=1; Message message=new Message(); Bundle bundle=new Bundle(); bundle.putInt("target_map_type", tager_map_type); message.setData(bundle); message.what=2; handler.sendMessage(message); //自定义对话框关闭 customDialog.cancel(); } }); //3d地图 ImageButton d3=(ImageButton) layout.findViewById(R.id.d3); d3.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { // TODO Auto-generated method stub tager_map_type=2; Message message=new Message(); Bundle bundle=new Bundle(); bundle.putInt("target_map_type", tager_map_type); message.setData(bundle); message.what=2; handler.sendMessage(message); //自定义对话框关闭 customDialog.cancel(); } }); return customDialog; }
MapView浮点按钮功能实现:
//是否显示路况信息标识 private boolean target_traffic=true; //显示地图类型(0:卫星地图、1:平面地图、2:3d地图) private int tager_map_type=1; //功能代码的编写 public void params(){ //交通类型 Button traffic=(Button) findViewById(R.id.traffic); traffic.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { Message message=new Message(); Bundle bundle=new Bundle(); bundle.putBoolean("traffic",target_traffic); message.setData(bundle); message.what=1; handler.sendMessage(message); } }); //地图类型(卫星地图、平面地图和三维地图) Button type=(Button) findViewById(R.id.type); type.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { //showDialog方法触发Activity的onCreateDialog(){可以自定义对话框样式} showDialog(0); } }); }
运行截图:
相关文章推荐
- (android地图开发) 高德地图添加自定义菜单栏
- (android地图开发) 高德地图自定义标题栏
- 最新基于高德地图的android进阶开发 GPS地图定位
- Android开发——AlertDialog自定义对话框
- Android开发之自定义对话框(2)—加入EditText
- (Android 地图开发) 高德地图添加覆盖物
- Android 高德地图2.80新版地图开发详解(本地定位/地图显示/Mark标记/camera移动和缩放)
- 高德地图Web端JavaScript API开发(一)---个性化展示(自定义地图)
- Android开发中如何创建自定义对话框
- (android地图开发) 高德地图手势切换
- Android开发之自定义对话框
- 最新基于高德地图的android进阶开发(3)GPS地图定位
- android开发之自定义对话框
- Android简明开发教程十八:自定义对话框 Transform
- Android高德地图开发(2)——地图显示+自定义控件
- (android 地图实战开发)3 在地图上显示当前位置和自定义银行位置
- android开发步步为营之25:开发自定义进度条对话框
- Android简明开发教程十八:自定义对话框 Transform
- Android开发笔记(六十六)自定义对话框
- Android简明开发教程十八:自定义对话框 Transform