2011年2月18日 星期五

DatePicker 和 Button Click 的小範例

範例內容跟 Android Developer 官方的範例其實有點類似
不過我個人傾向的事件寫法是在別的地方寫好 function
然後在設定 onClick 之類的事件時再指定到我寫好的 function
官方範例用下面這種寫法我覺得會讓程式碼很亂....

pucliv onCreate() {
  ...
  mPickDate.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
      showDialog(DATE_DIALOG_ID);
    }
  });
  ...
}

2011年2月14日 星期一

@+id/name 跟 @android:id/name 的差別

官方的文件 Declaring Layout 中有以下說明:

The at-symbol (@) at the beginning of the string indicates that the XML parser should parse and expand the rest of the ID string and identify it as an ID resource. The plus-symbol (+) means that this is a new resource name that must be created and added to our resources (in the R.java file). There are a number of other ID resources that are offered by the Android framework. When referencing an Android resource ID, you do not need the plus-symbol, but must add the android package namespace, like so:

android:id="@android:id/empty"

 

意即,@ 表示 XML parser 需要將接下來的字串轉換成 ID resource,其中 @+ 表示這是新的 resource name,必須新建到 R.java 內;@android:id 則表示指向的這個 resource name 是已經存在的 resource。

2011年1月5日 星期三

Google Maps 基本範例教學

Google 官方的教學:Hello, MapView
不過覺得官方的範例教學沒有圖,有些東西就搞不太清楚~

2011年1月3日 星期一

Android 入門的相關資源

gasolin 寫的 Android 入門教學
http://code.google.com/p/androidbmi/wiki/IntroAndroid

「Brad Free School 趙令文自由學校」,也是入門教學的網站
http://school.brad.tw/mod/resource/index.php?id=67

「Android學習筆記」,有一些比較基本的 Android 範例程式碼!
http://cooking-java.blogspot.com/search/label/Android

「A Visual Guide to Android GUI Widgets」,顯示 Android 上可用的一些 view 的長相,另外這個網站本身有提供 droiddraw 這個圖形化介面,可以幫助使用者快速產生 Android 需要的介面的 XML 檔。
http://www.droiddraw.org/widgetguide.html

「國立金門大學 九十六學年度資訊工程學系專題 Android教學範例」,有一些基本應用的範例,註解也寫得還蠻詳細的~
http://gogkmit.wikidot.com/start

「靈機一動:我的專案網」,有一些比較基本的 Android 程式教學
http://www.myproject.com.tw/node/19

2010年12月29日 星期三

C# 相對路徑轉絕對路徑

這篇是對應「C# 絕對路徑轉相對路徑」的程式碼所寫的~
目的就是把轉成相對路徑的位址再轉回成絕對路徑
僅供參考 XD。

用 OLEDB 讀寫 Excel 檔

其實原本是要直接讀寫 Excel 的,但時間上來不及讓我慢慢找相關資料
只大概知道可以用Microsoft.Office.Interop.Excel 來做
不過簡單測了一下卻出現 Excel 檔案打不開的問題(疑似是安全性問題之類的?)
另外還可以用 NPOI 函式庫,好像網路上蠻多人都用這個方法的。

用 OLEDB 把 Excel 當做小型資料庫來處理的話
主要缺點就是不支援 DELETE,只能 INSERT 和 UPDATE
所以遇到要 DELETE 時只能建新的 EXCEL,把要保留的 DataRow 都寫過去(INSERT)。

2010年12月2日 星期四

C# TextBox 雙擊、Ctrl+A 全選文字

C# 的 TextBox 控制項預設是沒有 Ctrl+A 可以全選的設計
所以只好一切都自己來了!

public mainForm() {
    /* 設定雙擊及 Ctrl+A 可全選 TextBox 控制項內的所有文字 */
    foreach (Control c in this.groupBox1.Controls) {
        if (c is TextBox) {
            c.KeyDown += new KeyEventHandler(allTextBox_KeyDown);
            c.DoubleClick += new EventHandler(allTextBox_DoubleClick);
        }
    }
}

/* 按下 Ctrl+A 全選文字 */
private void allTextBox_KeyDown(object sender, KeyEventArgs e) {
    if (e.Modifiers == Keys.Control && e.KeyCode == Keys.A)
        ((TextBox)sender).SelectAll();
}

/* 雙擊全選文字 */
private void allTextBox_DoubleClick(object sender, EventArgs e) {
    ((TextBox)sender).SelectAll();
}

2010年11月17日 星期三

ACCESS 不支援 LIMIT 的替代作法

SELECT TOP [pageSize] * FROM (SELECT TOP [pageSize*currentPage + 1] * FROM news WHERE constraint='constraint'  ORDER BY id DESC ) ORDER BY id ASC

其中紅色的地方 pageSize 是一頁顯示的筆數、currentPage 是現在要顯示的是第幾頁(假設起始序號是 0)。

2010年8月15日 星期日

PHP 版驗證碼產生器

http://samsharehome.blogspot.com/2008/12/phpgoogle.html
程式的限制是必須支援 PHP5 以及 GD
剛剛測試上傳到 phpnet 的伺服器是可以正常運作的
不過放在我本機的 Appserv 卻產生不出圖片,不知道為什麼Orz...

測試程式碼下載位置:http://sam.wang.0723.googlepages.com/verify.rar

參考圖: