2013年4月26日 星期五

android模擬器安裝中文輸入法


這次來寫一下 如何使用android模擬器安裝中文輸入法,

發現自己的android模擬器裡居然沒有中文輸入法,

但要輸入中文做測試居然不行= =

後來查到是說,

先去下載注音輸入法的apk檔,

Android 注音輸入法 這裡可以下載到
http://code.google.com/p/android-zhuyin-ime/downloads/list

把apk檔放到 android sdk目錄\android-sdk\platform-tools資料夾內

用終端機執行

./adb install ZhuYinIME_2010030801.apk

windows執行

adb install ZhuYinIME_2010030801.apk

開啟android 模擬器 點選 menu -> 系統設定 -> 語言與輸入設定 ->勾選注音輸入法

然後就可以了。

但是 在edittext中發現點了後還是出現英文的小鍵盤!!!

找不到哪裡切換的話,

只要在edittext長按滑鼠左鍵,就會跳出輸入法切換囉~!

2013年4月15日 星期一

webservice抓取namespace資訊

使用android連接web service時,會透過soap的library,

其連連線到web service需要填入web service 的name space,

要如何抓取namespace為何呢?

只要在你的web service網址後加上 wsdl,就可以看見  

targetNamespace="http://tempuri.org/"

 的資訊囉~

例如:





在activity group 使用dialog alert報錯

今天使用activity group的時候,

要在裡面加dialog alert,居然報錯,

我是用tab group -> 透過 activity group -> 載顯示的activity

在顯示的activity下dialog的語法發現以下error:

04-15 15:04:25.027: E/AndroidRuntime(31825): android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@40d861c0 is not valid; is your activity running?

查了網路後,

可以參考以下兩篇的作法

http://blog.csdn.net/biangren/article/details/7514722

http://blog.csdn.net/hillpool/article/details/7560600


實際作法, 加上 getParent() 即可


Builder b = new Builder(YourActivity.this.getParent());
b.setTitle("alertTitle");
b.setMessage("AlertMessage");
b.setPositiveButton("positive", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which)
{

}
});
b.show();

2013年4月14日 星期日

取消EditText Focus

在android native code裡,

若使用TextField(EditText)的話,

一進入預設會幫你直接focus在TextField(EditText),

有時候我們不需要一開始就focus在TextField(EditText),

可以在上層的Layout中加入兩行



LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:gravity="center"
        android rientation="horizontal" >

這樣就可以取消自動focus~



2013年4月10日 星期三

讓Android支援實體鍵盤

在開發Android 程式時,常常會使用到EditText 需要輸入文字,

但使用android的軟體鍵盤不太方便, 以下為開啟android模擬器支援實體鍵盤輸入的方式。

1. 開啟AVD

2. 點選你要選擇的模擬器(AVD Name)  點選Edit

3.在Hardware的部份,選擇New

4.在Property: 找到  Keyboard support 支援 實體鍵盤  (Keyboard lid support為支援虛擬鍵盤),按下OK。

5.在Value的部份把no改成yes

6.確定yes改好後,點選Edit AVD即可使用實體鍵盤。