菜要多喝水才會長大

心情日記

[Android] 在單一 Activity 切換不同 Layout

by GDX on 三月.07, 2010, under 心情日記

首先要先建立一個 LayoutInflater 實體

LayoutInflater mInflater = LayoutInflater.from(this);

接下來把我們需要的 Layouts 透過 inflate 方法讀進來

View mLayoutA = mInflater.inflate(R.layout.A, null);
View mLayoutB = mInflater.inflate(R.layout.B, null);
如此就可以在 Activity 內自由切換 Layout 了 :-)
setContentView(mLayoutA);
// do something …
setContentView(mLayoutB);
// do something …
Leave a Comment more...

修改 Blackberry Plugin for Eclipse 的模擬器位置

by GDX on 二月.08, 2010, under 心情日記

找了很久終於找到了…把 Eclipse 直接轉移到筆電卻發生模擬器無法啟動
模擬器位置設定檔在:

Eclipse目錄/plugins/net.rim.ejde.componentpack{版本號}\components\bin\Settings.rc

用文字編輯器打開修改 Simulator 相關參數即可

Leave a Comment more...

如何用 C# 在執行階段建立新的 Class instance

by GDX on 一月.24, 2010, under 心情日記

利用 Class name

Type type = Type.GetType(className);

Object obj = Activator.CreateInstance(type);

Activator.CreateInstance 提供了許多多載方法

詳見 MSDN  參考資料

Leave a Comment more...

被噗浪嚇到

by GDX on 十二月.11, 2009, under 心情日記

剛剛 Plurk 到一半 (2009/12/11  21:05)突然發現出現不明的錯誤
試了好幾次都一樣,於是就把頁面重整,結果~
居然出現了下面的訊息!!!???

gdx-is-not-found

gdx-is-not-found

這是…被砍帳號了嗎…囧rz?
我寶貴的訊息都在裡面阿~~還有許多作的筆記~~沒了我要怎麼辦阿~~>』<

不過後來連到其他人的 Plurk 頁面都出現一樣的訊息
於是重回 Plurk 首頁:

plurk-error

plurk-error

看來是 Plurk 本身網站有問題,差點沒嚇死我 Q_Q

2009/12/11 21:19更新:
Plurk 已經回覆,看來是短暫的問題而已。

Leave a Comment :, , more...

SQL – 分頁

by GDX on 十二月.09, 2009, under SQL, 心情日記, 資料庫

以前還沒有那麼熟SQL語法的時候
只會作將資料庫資料讀出來、寫入、更新等等基本的動作,以為這就是SQL的全部了
後來作的東西越來越多、看的越來越多,經驗也比以前豐富了
發現SQL真是博大精深,很多複雜的動作都可以在SQL裡完成
而不需要將資料讀出再交由程式作處理,也減少了程式的複雜度

例如最常用到的分頁,以前總想著把資料全部讀出來再用程式選取需要的資料
但這樣實在太浪費校能和記憶體了
資料量小倒是還好,當資料量一大,成千上萬筆的資料不可能一次選出
因此在此做了筆記

範例資料表名稱: a
範例資料表結構:
id: 主索引
data: 資料

利用以下語法即可達到不需程式控制的分頁技巧

SELECT TOP pSize * FROM [a]
WHERE [a].[id] NOT IN
(SELECT TOP pSize * pIndex [b].[id] FROM [a] AS [b] ORDER BY [b].[id])
ORDER BY [a].[id] DESC

pSize代表一頁的資料筆數
pIndex代表目前的頁面(從0開始)

Leave a Comment :, , , more...

利用http protocal直接取得GoogleMaps的圖片

by GDX on 十二月.09, 2009, under 心情日記

GoogleMaps 目前並未有公開提供給應用程式的API
之前在使用手機上網的時候發現了GoogleMaps的手機網頁版本是直接顯示地圖圖片的
因此大致看了一下上面的圖片網址,發現可以直接透過輸入網址來取圖

範例網址:
http://maps.google.com/mapdata?Point=b&Point.latitude_e6=23000944&Point.longitude_e6=120180160&Point.iconid=17&Point=e&zm=33900&w=113&h=113&cc=&min_priority=3&client=internal-mobilefe&zl=7

參數說明:
Point=b和Point=e:代表一個點的開始和結尾
Point.latitude_e6:緯度 (無小數點,小數取到第六位)
Point.longitude_e6:經度(無小數點,小數取到第六位)
w:取得的圖片寬度
h:取得的圖片高度
cc:目前好像沒用
min_priority:試著去改過,不過好像沒什麼作用
client:照著輸入即可
zl:縮放比例 (0~17)
zm:應該是Zoom Meter,計算方式為 (zl + 1) * w

Leave a Comment :, , more...

個人網誌開張囉!

by GDX on 十二月.09, 2009, under 心情日記

第一篇文章 :-)

Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Archives

All entries, chronologically...