package baidumapsdk.demo;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView; import com.baidu.mapapi.SDKInitializer;
import com.baidu.mapapi.VersionInfo; public class BMapApiDemoMain extends Activity {
private static final String LTAG = BMapApiDemoMain.class.getSimpleName(); /**
* 构造广播监听类,监听 SDK key 验证以及网络异常广播
*/
public class SDKReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
String s = intent.getAction();
Log.d(LTAG, "action: " + s);
TextView text = (TextView) findViewById(R.id.text_Info);
text.setTextColor(Color.RED);
if (s.equals(SDKInitializer.SDK_BROADTCAST_ACTION_STRING_PERMISSION_CHECK_ERROR)) {
text.setText("key 验证出错! 请在 AndroidManifest.xml 文件中检查 key 设置");
} else if (s
.equals(SDKInitializer.SDK_BROADCAST_ACTION_STRING_NETWORK_ERROR)) {
text.setText("网络出错");
}
}
} private SDKReceiver mReceiver; @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView text = (TextView) findViewById(R.id.text_Info);
text.setTextColor(Color.YELLOW);
text.setText("欢迎使用百度地图Android SDK v" + VersionInfo.getApiVersion());
ListView mListView = (ListView) findViewById(R.id.listView);
// 添加ListItem,设置事件响应
mListView.setAdapter(new DemoListAdapter());
mListView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View v, int index,
long arg3) {
onListItemClick(index);
}
}); // 注册 SDK 广播监听者
IntentFilter iFilter = new IntentFilter();
iFilter.addAction(SDKInitializer.SDK_BROADTCAST_ACTION_STRING_PERMISSION_CHECK_ERROR);
iFilter.addAction(SDKInitializer.SDK_BROADCAST_ACTION_STRING_NETWORK_ERROR);
mReceiver = new SDKReceiver();
registerReceiver(mReceiver, iFilter);
} void onListItemClick(int index) {
Intent intent = null;
intent = new Intent(BMapApiDemoMain.this, demos[index].demoClass);
this.startActivity(intent);
} private static final DemoInfo[] demos = {
new DemoInfo(R.string.demo_title_basemap,
R.string.demo_desc_basemap, BaseMapDemo.class),
new DemoInfo(R.string.demo_title_map_fragment,
R.string.demo_desc_map_fragment, MapFragmentDemo.class),
new DemoInfo(R.string.demo_title_layers, R.string.demo_desc_layers,
LayersDemo.class),
new DemoInfo(R.string.demo_title_multimap,
R.string.demo_desc_multimap, MultiMapViewDemo.class),
new DemoInfo(R.string.demo_title_control,
R.string.demo_desc_control, MapControlDemo.class),
new DemoInfo(R.string.demo_title_ui, R.string.demo_desc_ui,
UISettingDemo.class),
new DemoInfo(R.string.demo_title_location,
R.string.demo_desc_location, LocationDemo.class),
new DemoInfo(R.string.demo_title_geometry,
R.string.demo_desc_geometry, GeometryDemo.class),
new DemoInfo(R.string.demo_title_overlay,
R.string.demo_desc_overlay, OverlayDemo.class),
new DemoInfo(R.string.demo_title_heatmap, R.string.demo_desc_heatmap,
HeatMapDemo.class),
new DemoInfo(R.string.demo_title_geocode,
R.string.demo_desc_geocode, GeoCoderDemo.class),
new DemoInfo(R.string.demo_title_poi, R.string.demo_desc_poi,
PoiSearchDemo.class),
new DemoInfo(R.string.demo_title_route, R.string.demo_desc_route,
RoutePlanDemo.class),
new DemoInfo(R.string.demo_title_bus, R.string.demo_desc_bus,
BusLineSearchDemo.class),
new DemoInfo(R.string.demo_title_share, R.string.demo_desc_share,
ShareDemo.class),
new DemoInfo(R.string.demo_title_offline,
R.string.demo_desc_offline, OfflineDemo.class),
new DemoInfo(R.string.demo_title_radar,
R.string.demo_desc_radar, RadarDemo.class),
new DemoInfo(R.string.demo_title_open_baidumap, R.string.demo_desc_open_baidumap,
OpenBaiduMap.class),
new DemoInfo(R.string.demo_title_favorite,
R.string.demo_desc_favorite, FavoriteDemo.class),
new DemoInfo(R.string.demo_title_cloud, R.string.demo_desc_cloud,
CloudSearchDemo.class),
new DemoInfo(R.string.demo_title_opengl, R.string.demo_desc_opengl,
OpenglDemo.class)
}; @Override
protected void onResume() {
super.onResume();
} @Override
protected void onDestroy() {
super.onDestroy();
// 取消监听 SDK 广播
unregisterReceiver(mReceiver);
} private class DemoListAdapter extends BaseAdapter {
public DemoListAdapter() {
super();
} @Override
public View getView(int index, View convertView, ViewGroup parent) {
convertView = View.inflate(BMapApiDemoMain.this,
R.layout.demo_info_item, null);
TextView title = (TextView) convertView.findViewById(R.id.title);
TextView desc = (TextView) convertView.findViewById(R.id.desc);
title.setText(demos[index].title);
desc.setText(demos[index].desc);
if (index >= 16) {
title.setTextColor(Color.YELLOW);
}
return convertView;
} @Override
public int getCount() {
return demos.length;
} @Override
public Object getItem(int index) {
return demos[index];
} @Override
public long getItemId(int id) {
return id;
}
} private static class DemoInfo {
private final int title;
private final int desc;
private final Class<? extends android.app.Activity> demoClass; public DemoInfo(int title, int desc,
Class<? extends android.app.Activity> demoClass) {
this.title = title;
this.desc = desc;
this.demoClass = demoClass;
}
}
}

  

页面类跳转Demo的更多相关文章

  1. 简单单页面路由跳转demo

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. 【swift学习笔记】二.页面转跳数据回传

    上一篇我们介绍了页面转跳:[swift学习笔记]一.页面转跳的条件判断和传值 这一篇说一下如何把数据回传回父页面,如下图所示,这个例子很简单,只是把传过去的数据加上了"回传"两个字 ...

  3. 3.servlet实现页面的跳转

    效果: 在网页的输入框中输入lily,跳到成功的页面(请求转发),输入的不是lily则跳到百度的页面(跳到工程之外的页面,则是请求重定向) 1.建Web project“2Servlet_Basic” ...

  4. window.location.reload();页面实现跳转和刷新

    1 history.go(0)2 location.reload()3 location=location4 location.assign(location)5 document.execComma ...

  5. HTML页面自动跳转,windows操作

    1) html的实现 <head> <!-- 以下方式只是刷新不跳转到其他页面 --> <meta http-equiv="refresh" cont ...

  6. Android笔记-4-实现登陆页面并跳转和简单的注册页面

    实现登陆页面并跳转和简单的注册页面   首先我们来看看布局的xml代码 login.xml <span style="font-family:Arial;font-size:18px; ...

  7. [Xcode 实际操作]九、实用进阶-(24)使用Segue(页面的跳转连接)进行页面跳转并传递参数

    目录:[Swift]Xcode实际操作 本文将演示使用Segue(页面的跳转连接)进行页面跳转并传递参数. 参照结合:[Xcode10 实际操作]九.实用进阶-(23)多个Storyboard故事板中 ...

  8. 苹果手机Safari无痕浏览模式下系统登录成功但是页面不跳转

    昨天下午,测试提了一个bug,问题是:在苹果手机Safari无痕浏览模式下系统登录成功但是页面不跳转. 思前想后找了半天没思路,后来经过同事的点拨,说可能是禁用了cookie之类的,反正我也没思路就顺 ...

  9. JS定时刷新页面及跳转页面

    JS定时刷新页面及跳转页面 Javascript 返回上一页1. Javascript 返回上一页 history.go(-1), 返回两个页面: history.go(-2); 2. history ...

随机推荐

  1. SharePoint 2013 代码实现自定义的站点模版创建Site Collection

    先需要将自定义的站点模版从网站集转移到Farm中. 找一个自己已经完成配置及设计的网站,在网站设置里面选择另存为模版.要注意的是不是所有的站点类型都有另存为模版的功能. 存完之后可在解决方案库的界面里 ...

  2. spark JavaDirectKafkaWordCount 例子分析

    spark  JavaDirectKafkaWordCount 例子分析: 1. KafkaUtils.createDirectStream( jssc, String.class, String.c ...

  3. zoj 1149 Dividing

    1到6的卡分别各有有限制的张数,问能不能恰好分,总张数不能超过20000. 很明显是多重背包问题,上去果写了个三重循环,然后就T了,重新打开背包九讲,找到了多重背包的二进制拆分优化,把其中一维n的复杂 ...

  4. linux下socket编程-TCP

    网络字节序 发送主机通常将发送缓冲区中的数据按内存地址从低到高的顺序发出,接收主机把从网络上接到的字节依次保存在接收缓冲区中,也是按内存地址从低到高的顺序保存,因此,网络数据流的地址应这样规定:先发出 ...

  5. sulime运行 java 和 php

    执行php脚本 1. 先配置好php环境变量 2. Tools -> Build System -> New Build System.... {      "cmd" ...

  6. mysql5.6 zip版安装

    MySQL安装文件分为两种,一种是msi格式的,一种是zip格式的.如果是msi格式的可以直接点击安装,按照它给出的安装提示进行安装(相信大家的英文可以看懂英文提示),一般MySQL将会安装在C:\P ...

  7. 禁止select下拉框的其中某个选择项不能被选择

    <select name='Grade' class='s8'> <option value=''>— 请选择 —</option>? <optgroup l ...

  8. 算法_php猴子选大王_约瑟夫问题

    题目: n个猴子围坐一圈,从第一个猴子开始数,到第m个出列,求最后一个猴子的编号. 分析: 首先想到循环,然后队列,然后堆,所以用数组模拟一个循环的列表,下标为[0-(n-1)],下标+1整除m干掉元 ...

  9. Promise原理 && 简单实现

    Promise原理 参考https://github.com/chunpu/promise/blob/master/promise.js 个人认为原博的实现有点问题 在next函数的实现上, 会导致无 ...

  10. VS2008下WinRar源码生成dll和 lib总结

    WinRar官方提供了源码(http://www.rarlab.com/rar_add.htm):如果自己想要修改里面的内容就要重新生成DLL和LIB,我在网上找了很多资料都没有说得很清楚.花一两天的 ...