2012年11月22日 星期四

Java RFC3986 URL Encode

http://designdotworks.blogspot.tw/2009/05/java-urlencode.html

因為在Java這邊目前沒有找到比較好的 RFC3986 規格的 URLEncode 。
也就是除了 a-zA-Z0-9 和 -_.~ 這四個符號,其他都要被 encode 過。 不過跟網頁內不同的是,我是改成


  1. encoded = encoded.replace("*""%2A");  
  2. encoded = encoded.replace("%7E""~");  
  3. encoded = encoded.replace("+""%20");  

Android findViewById Dynamically

http://stackoverflow.com/questions/3806847/how-to-create-findviewbyid-parm-dynamically-or-programmatically-at-runtime


int id = getResources().getIdentifier("cell00", "id", getPackageName());
TextView currcell = (TextView) findViewById(id); 

2012年11月21日 星期三

Put MapView In ScrollView

參考:http://stackoverflow.com/questions/6546108/mapview-inside-a-scrollview

簡單說就是讓ScrollView內的那一層不要接收Touch事件


@Override
public boolean onTouchEvent(MotionEvent ev) {
    int action = ev.getAction();
    switch (action) {
    case MotionEvent.ACTION_DOWN:
        // Disallow ScrollView to intercept touch events.
        this.getParent().requestDisallowInterceptTouchEvent(true);
        break;

    case MotionEvent.ACTION_UP:
        // Allow ScrollView to intercept touch events.
        this.getParent().requestDisallowInterceptTouchEvent(false);
        break;
    }

    // Handle MapView's touch events.
    super.onTouchEvent(ev);
    return true;
}