页面类跳转Demo

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;
		}
	}
}

  

时间: 2024-08-28 08:54:33

页面类跳转Demo的相关文章

浅聊四个主流的页面间跳转动效

  最近一直在做交互规范总结的工作,在不断梳理页面间跳转逻辑的同时,发现页面间的逻辑关系并不能和页面间跳转的动效很好的结合上.虽然只是零点几秒的切换动效,却能在一定程度上影响用户对于页面间逻辑的认知.为了输出详细的规范,花了大量时间把玩现在公司线上的产品以及国内外优秀的APP,尤其是苹果.谷歌自己开发的APP.(如果某些方面在设计规范中并没有给出答案,就在原生APP中找答案吧!) 转场动效也是在APP中应用最多的动效,连接两个页面.通过合理的动效让户能更清楚我从哪里来,现在在哪,怎么回去等一系列

jsp 页面传值-JSP 利用超链接页面转跳传值为空,如何解决

问题描述 JSP 利用超链接页面转跳传值为空,如何解决 <%@ page contentType="text/html;charset=gb2312"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN&q

网站页面自动跳转实现方法PHP、JSP(下)_javascript技巧

本文讨论网页自动跳转的几种实现方法.方法一:使用meta标签meta标签是html不可或缺的标签之一,它负责提供文档的元信息,其参数主要有: ① http-equiv: 与 文档中数据相关的HTTP文件首部 ② content: 与命名HTTP首部相关的数据 ③ name: 文档描述 ④ url: 与元信息相联系的URL当我们定义属性http-equiv为refresh,打开此Web页时系统将根据content规定的值在一定时间内跳转到相应页面,content="秒数;url=网址"就

Android启动页面定时跳转的三种方法_Android

从我所做的项目来看,几乎都少不了开始页面,启动页面的作用能够打广告.发公告.做缓存处理.更新数据等等!Android实现开始页面的跳转,就是打开一个Android手机APP的欢迎界面后跳转到指定界面,下面就让我简单介绍下比较常用的开始页面的跳转方法吧. 一.在onCreate里设置个Timer,然后建立Intent指向你要调用的Activity.设置Timer 任意秒后执行startActivity即可!(Timer是一种定时器工具,用来在一个后台线程计划执行指定任务,它可以计划执行一个任务一次

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

上一篇我们介绍了页面转跳:[swift学习笔记]一.页面转跳的条件判断和传值 这一篇说一下如何把数据回传回父页面,如下图所示,这个例子很简单,只是把传过去的数据加上了"回传"两个字,回传到父页面. 我是使用protocol去实现的回传.那让我们来创建一个protocol import Foundation protocol ValueBackDelegate { func ValueBack(value: String) } protocol可以理解为interface,ValueBa

jsp页面如何跳转到html页面,在线急等!

问题描述 jsp页面如何跳转到html页面,在线急等! jsp页面如何跳转到html页面,用按钮,求大神!!!!!!!!!!!!!!!!!!!!!! 解决方案 jsp的几种跳转方法:http://jingyan.baidu.com/article/ed15cb1b14d9201be3698183.html 解决方案二: response.Redirect或者js跳转:window.location=新的地址 解决方案三: http://blog.csdn.net/a597926661/artic

导出Excel时页面不跳转的技巧

今天在点击客户档案导出的时候,发现先是打开了一个新标签,然后新标签自动关掉,弹出一个文件 下载确认的窗口,点击确认后开始下载导出的Excel文件.这样的过程感觉窗口闪来闪去,而且可能会给 用户带来困惑,是一种不好的体验. 检查了一下代码,发现这跟采用服务端导出数据的处理方式有关系,本身整个过程的原理是客户端用 POST方式提交表单到服务端,target属性设为空,服务端查询出要导出的数据并且组织成数组并生成 header信息为文件,内容类型为application/vnd.ms-excel的响应

JS定时刷新页面及跳转页面的方法

Javascript 返回上一页1. Javascript 返回上一页 history.go(-1), 返回两个页面: history.go(-2); 2. history.back(). 3. window.history.forward()返回下一页 4. window.history.go(返回第几页,也可以使用访问过的URL) 例: 复制代码 代码如下: <a href="javascript:history.go(-1);">向上一页</a> resp

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

 Javascript 返回上一页 1. Javascript 返回上一页 history.go(-1), 返回两个页面: history.go(-2); 2. history.back(). 3. window.history.forward()返回下一页 4. window.history.go(返回第几页,也可以使用访问过的URL) 例: <a href="javascript:history.go(-1);">向上一页</a> response.Writ