当前位置: 编程技术>移动开发
本页文章导读:
▪mars老师的googleMap(1) mars老师的googleMap(一)
一、申请 Apikey Apikey Apikey Apikey ,并放在正确的位置这个应该都知道,但是是申请得到的 key 放哪里很多人不知道,可以放在1 、 XML 布局文件中代码 : 全选<view and.........
▪ Activity完整跳转事例 Activity完整跳转例子
例子:package com.cn;
import com.util.ProgressActivity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import .........
▪ 资源上载 资源下载
http://download.csdn.net/detail/beyondandroid/3685257 驾校一点通-----[图标]http://www.zcool.com.cn/gfx/ZMTgxMTE2.htmlhttp://www.zcool.com.cn/gfx/ZMTgxMTIw.htmlhttp://www.zcool.com.cn/gfx/ZODI5Njg=.htmlhttp://www.zcool.com.cn/gf.........
[1]mars老师的googleMap(1)
来源: 互联网 发布时间: 2014-02-18
mars老师的googleMap(一)
一、申请 Apikey Apikey Apikey Apikey ,并放在正确的位置
这个应该都知道,但是是申请得到的 key 放哪里很多人不知道,可以放在
1 、 XML 布局文件中
代码 : 全选
<view android:id="@+id/mv"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:apiKey="01Yu9W3X3vbpYT3x33chPXXX7U1Z6jy8WYZXNFA"
/>
2 、 java 中
mMapView = new MapView(this, "01Yu9W3X3vbpYT3x33chPxxx7U1Z6jy8WYZ
二、记得导入 uses-library uses-library uses-library uses-library
由于 1.0 版本的修改,使得 map 包不再是默认的了,使用的时候需要在 manife
点下加入
<uses-library android:name="com.google.android.maps" />
否则,你将遇到可恶的 “ java.lang.NoClassDefFoundError: ” ,切记!
三、需要给予一定的权限
因为要使用 GoogleMAP 的 service ,所以需要
<uses-permission android:name="android.permission.INTERNET"></uses-permissio
如果需要 GPS 等应用,还需要
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"
四、 Activity Activity Activity Activity 需要继承自 MapActivity MapActivity MapActivity MapActivity
类似如下代码;
代码 : 全选
package com.iceskysl.showmap;
import com.google.android.maps.MapActivity;
import android.os.Bundle;
public class ShowMap extends MapActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
一、申请 Apikey Apikey Apikey Apikey ,并放在正确的位置
这个应该都知道,但是是申请得到的 key 放哪里很多人不知道,可以放在
1 、 XML 布局文件中
代码 : 全选
<view android:id="@+id/mv"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:apiKey="01Yu9W3X3vbpYT3x33chPXXX7U1Z6jy8WYZXNFA"
/>
2 、 java 中
mMapView = new MapView(this, "01Yu9W3X3vbpYT3x33chPxxx7U1Z6jy8WYZ
二、记得导入 uses-library uses-library uses-library uses-library
由于 1.0 版本的修改,使得 map 包不再是默认的了,使用的时候需要在 manife
点下加入
<uses-library android:name="com.google.android.maps" />
否则,你将遇到可恶的 “ java.lang.NoClassDefFoundError: ” ,切记!
三、需要给予一定的权限
因为要使用 GoogleMAP 的 service ,所以需要
<uses-permission android:name="android.permission.INTERNET"></uses-permissio
如果需要 GPS 等应用,还需要
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"
四、 Activity Activity Activity Activity 需要继承自 MapActivity MapActivity MapActivity MapActivity
类似如下代码;
代码 : 全选
package com.iceskysl.showmap;
import com.google.android.maps.MapActivity;
import android.os.Bundle;
public class ShowMap extends MapActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
[2] Activity完整跳转事例
来源: 互联网 发布时间: 2014-02-18
Activity完整跳转例子
例子:
在AndroidManifest.xml中两个activity.
例子:
package com.cn;
import com.util.ProgressActivity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MycadillacActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btn1 = (Button)findViewById(R.id.login);
btn1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent1 = new Intent(MycadillacActivity.this,ProgressActivity.class);
MycadillacActivity.this.startActivityForResult(intent1, 10);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
String name = data.getExtras().get("name").toString();
System.out.println("requestCode:"+requestCode+" resultCode:"+resultCode+" name:"+name);
super.onActivityResult(requestCode, resultCode, data);
}
}package com.util;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import com.cn.R;
public class ProgressActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.progress);
super.onCreate(savedInstanceState);
Button btn1 = (Button)findViewById(R.id.button1);
btn1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent i = new Intent();
i.putExtra("name", "11");
ProgressActivity.this.setResult(5, i);
ProgressActivity.this.finish();
}
});
}
}
在AndroidManifest.xml中两个activity.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cn"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".MycadillacActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.util.ProgressActivity" android:theme="@android:style/Theme.Dialog"></activity>
</application>
</manifest>
[3] 资源上载
来源: 互联网 发布时间: 2014-02-18
资源下载
http://download.csdn.net/detail/beyondandroid/3685257 驾校一点通
-----[图标]
http://www.zcool.com.cn/gfx/ZMTgxMTE2.html
http://www.zcool.com.cn/gfx/ZMTgxMTIw.html
http://www.zcool.com.cn/gfx/ZODI5Njg=.html
http://www.zcool.com.cn/gfx/ZMTgwMTcy.html【播放器按钮】
http://www.zcool.com.cn/gfx/ZMTA5NzEy.html
http://download.csdn.net/detail/beyondandroid/3685257 驾校一点通
-----[图标]
http://www.zcool.com.cn/gfx/ZMTgxMTE2.html
http://www.zcool.com.cn/gfx/ZMTgxMTIw.html
http://www.zcool.com.cn/gfx/ZODI5Njg=.html
http://www.zcool.com.cn/gfx/ZMTgwMTcy.html【播放器按钮】
http://www.zcool.com.cn/gfx/ZMTA5NzEy.html
最新技术文章: