2012年4月26日 星期四

[Android] Custom ListView

介紹如何使用 ListView
ListView之一:Adapter介紹與使用

如何產生 separated header
Separating Lists with Headers in Android 0.9

當我們使用 custom background 時, 如果 scroll ListView
會發現出現黑色的背景, 這個問題的原因如下:

ListView 使用 transparent background, 但是在 scroll 時
會用 cache color hint 來當作背景以加速繪圖
詳細的說明在此 http://developer.android.com/resources/articles/listview-backgrounds.html

因此, 我們可以用 ListView::setColorHint() 或是 xml 來改變 scroll 時
會出現的背景色, 或設為 #00000000


2012年4月16日 星期一

[Android] google map api



要開發一個 google map activity 最先要繼承 MapActivity
拉一個有<com.google.android.maps.MapView /> 的 layout
在使用 MapView 時你會先要先註冊 api key

以下是常用的方法

初始化 MapView

MapController mc = mMapView.getController(); mc.setZoom(INITIAL_ZOOM_LEVEL); mc.setCenter(new GeoPoint(INITIAL_LATITUDE, INITIAL_LONGITUDE));
從螢幕座標取得地圖上的經緯度

GeoPoint tap = mapView.getProjection().fromPixels()
取得附近景點經緯度

Geocoder geoCoder = new Geocoder(this); List<Address> list = geoCoder.getFromLocationName("景點", 10);
靜態擷圖

URL url = new URL("http://maps.google.com/maps/api/staticmap?size=64x64&sensor=true&language=zh-tw&markers=color:purple|size:small|" + latitude + "," + longitude + "&zoom=15&scale=2");
URLConnection urlConn = url.openConnection();
urlConn.connect();
InputStream is = urlConn.getInputStream();
Bitmap thumb = BitmapFactory.decodeStream(is);
is.close();

直接使用 Google Map, 可以參考
http://jax-work-archive.blogspot.com/2011/07/google-maps.html
[example http://maps.google.com/maps?q=7-11&near=24.8039455,120.9646866&z=15]


其它參考資料
http://code.google.com/intl/zh-TW/android/add-ons/google-apis/reference/com/google/android/maps/MapView.html
http://www.myandroid.tw/bbs-topic-962.sea
http://itpower.blueshop.com.tw/?p=345 規劃導航路徑 Directions Route

Python Tkinter First Example

import tkinter as tk def on_closing():     root.destroy() class MainWindow(tk.Tk):     def __init__(self, *args, **kwargs):         tk.Tk.__...