2016年2月16日 星期二

EditText & AUtoComplet TextView

<EditText
        android:inputType="number" //定義欄位屬性,會自動跳出對應的鍵盤
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/editText1"
        android:hint="數字 EditText" /> //欄位提示字元


inputType屬性表

說明
none
text任何的字元
textCapCharacters鍵盤英文為大寫
textCapWords每一個英文單字字母為大寫
textAutoCorrect自動完成,表示輸入完成後會自動跳入下一個EditText
textAutoComplete同textAutoCorrect
textMultiLine多行輸入
textImeMultiLine輸入法多行(不一定有支援)
textNoSuggestions不提示
textUri網址
textEmailAddressEmail 地址
textEmailSubjectEmail 主旨
textShortMessage短訊息
textLongMessage長訊息
textPersonName人名
textPostalAddress地址
textPassword密碼
textVisiblePassword可見密碼
textWebEditText網頁表單的本文格式
textFilter本文篩選格式
textPhonetic拼音輸入
number數字鍵盤
 numberSigned帶有符號數字格式
numberDecimal帶小數點的浮點數字格式
phone電話格式
datetime時間日期
date日期鍵盤
time時間鍵盤

<AutoCompleteTextView
        android:hint="自動完成"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/txtAutoComplete" />

.cs檔內容(Adapter用法)
 //AutoCompleteTextView
            string[] data = { "aaa","abc", "abb", "app", "apk"}

            //由資料來源建立Adapter
            ArrayAdapter<string> source = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleDropDownItem1Line, data);
            var txt = this.FindViewById<AutoCompleteTextView>(Resource.Id.txtAutoComplete);

            //將資料Adapter設定給AutoCompleteTextView
            txt.Adapter = source;
            txt.Threshold = 1;//設定輸入幾個字後跳提示,預設為2 


data(字串) ==> Adapter ==> AutoCompleteTextView

沒有留言:

張貼留言