今天弄了个程序,如果用户没有安装谷歌地图的api(Google Map feature)那我就在应用中取消有关地图的功能,也就不需要安装(Google Map),如何不安装Google Map呢
<uses-library android:name="com.google.android.maps" android:required="false" />
只在2.0+测试通过 1.5 1.6 我没测试成功
测试url:
http://ditu.google.cn/maps/geo?output=csv&key=abcdef&hl=zh-CN&q=22.660648,113.171355
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
public class ditu {
public static void main(String[] args) {
String addr = geocodeAddr(29.840644,111.093750);//(38.9146943,121.612382);
System.out.println(addr);
}
public static String geocodeAddr(Double latitude, Double longitude) {
String addr = "";
//密钥可以随便写一个key=abc
String url = String.format("http://ditu.google.cn/maps/geo?output=csv&key=abcdef&hl=zh-CN&q=%f,%f",latitude, longitude);
URL myURL = null;
URLConnection httpsConn = null;
try {
myURL = new URL(/blog_article/url/index.html);
} catch (MalformedURLException e) {
e.printStackTrace();
return null;
}
try {
httpsConn = (URLConnection) myURL.openConnection();
if (httpsConn != null) {
InputStreamReader insr = new InputStreamReader(httpsConn.getInputStream());
BufferedReader br = new BufferedReader(insr);
String data = null;
if ((data = br.readLine()) != null)
{
String[] retList = data.split(",");
if (retList.length>2 && ("200".equals(retList[0]))) {
addr = retList[2];
}
}
insr.close();
}
} catch (IOException e) {
e.printStackTrace();
return null;
}
return addr = addr.replace("\"", "");
}
}
显示:
[self.navigationController setNavigationBarHidden:NO animated:YES];
隐藏:
[self.navigationController setNavigationBarHidden:YES animated:YES];
隐藏返回键
self.navigationItem.hidesBackButton = YES;
p.p1 {margin: 0.0px 0.0px 12.0px 0.0px; text-align: justify; line-height: 18.0px; font: 12.0px 'Lucida Grande'; color: #444444} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 15.0px; font: 12.0px Courier; color: #110000; background-color: #f9f9f9} span.s1 {color: #012300} span.s2 {color: #a61490}
Navigation Controller 是最重要的iPhone组建之一了,以下是一些“关键方法”
pushViewController:viewController animated:BOOL
(加载视图控制器)
– 添加指定的视图控制器并予以显示,后接:是否动画显示
popViewControllerAnimated:BOOL
(弹出当前视图控制器)
– 弹出并向左显示前一个视图
popToViewController:viewController animated:BOOL
(弹出到指定视图控制器)
– 回到指定视图控制器, 也就是不只弹出一个
popToRootViewControllerAnimated:BOOL
(弹出到根视图控制器)
– 比如说你有一个“Home”键,也许就会实施这个方法了。
setNavigationBarHidden:BOOL animated:BOOL