04 高级控件总结
1,Spinner
?? ?>概念;下拉菜單控件 默認顯示當(dāng)前選擇的項(第一次展示集合中第一條數(shù)據(jù))
?? ?>屬性:
?? ??? ?android:entries="@array/books"? 展示數(shù)據(jù)? (note:提前知道數(shù)據(jù)是什么 )
?? ????? android:spinnerMode="dropdown" spinner 樣式
?? ????? dropdown:下拉列表???? 設(shè)置popupBackground? 每一項的背景顏色
?? ????? dialog:彈出框????????????? 設(shè)置prompt?? 標(biāo)題????? 調(diào)用的是Values/string.xml/string ?
???? >監(jiān)聽:setOnItemSelectedListener
?? ?
2,什么是Adapter?
?? ?>適配器? 將數(shù)據(jù)轉(zhuǎn)換成控件識別的形式
?? ?>子類:BaseAdapter(下周)??? ArrayAdapter???? SimpleAdapter
?? ?
3,ArrayAdapter的使用?
?? ?>一般用于只有String類型數(shù)據(jù)? 展示到TextView上
?? ?>如果三個參數(shù)的ArrayAdapter?? item布局的根節(jié)點 必須是TextView
???????? 如果跟節(jié)點不是TextVIew 三個參數(shù)的會報錯????? 使用四個參數(shù)的ArrayAdapter
?? ?
4,SimpleAdapter的使用:
?? ?>處理復(fù)雜的數(shù)據(jù)?? (帶有圖片和文字)
?? ??? Context context:?? 上下文
?????????? List<? extends Map<String, ?>> data:? 數(shù)據(jù)源
???????????? int resource:? 布局
???????????? String[] from:? 數(shù)據(jù)源中帶key的數(shù)組
???????????? int[] to???? :? 布局資源中id的數(shù)組
??????????? ?
???????????? note:from里的key和to里的控件id? 是對應(yīng)關(guān)系
5,AutoCompleteTextView
?? ?>自動索引的EditText(文本輸入框)
?? ?> 默認輸入倆個字符? 才開始索引
????????? android:completionThreshold="1" 輸入幾個字符開始索引
?? ??? ?
6,addTextChangedListener()的用法?
?? ?>
?? ?
?????? ?
??????? //文本發(fā)生變化的監(jiān)聽?? 可以對EditText操作 ?
??????? autoView.addTextChangedListener(new TextWatcher() {
?? ??? ??? ?
?????? ??? ?/**
?????? ??? ? * 改變文本時調(diào)用
?????? ??? ? * CharSequence s:變化之后的文本
?????? ??? ? * int start:變化的起點? 從哪里開始改變
?????? ??? ? * int before: 相比較文本變化? 添加沒有改變0???? 刪除改變
?????? ??? ? * int count:相比較文本變化???? 添加有值????????? 刪除沒有改變0
?????? ??? ? */
?? ??? ??? ?@Override
?? ??? ??? ?public void onTextChanged(CharSequence s, int start, int before, int count) {
?? ??? ??? ??? ?// TODO Auto-generated method stub
?? ??? ??? ??? ?Log.e("AAA", "==onTextChanged==s:"+s+"=start:"+start+"=before:"+before+"=count:"+count);
?? ??? ??? ?}
?? ??? ??? ?
?? ??? ??? ?/**
?????? ??? ? * 改變文本之前調(diào)用
?????? ??? ? * CharSequence s:變化之前的文本
?????? ??? ? * int start:變化之前的文本下標(biāo)
?????? ??? ? * int count:相比較文本的變化?? 添加不變的0?? 刪除是改變:刪除幾個展示結(jié)果
?????? ??? ? * int after:相比較文本的變化???? 如果添加是有值??? 如果刪除不變?? 0
?????? ??? ? */
?? ??? ??? ?@Override
?? ??? ??? ?public void beforeTextChanged(CharSequence s, int start, int count,
?? ??? ??? ??? ??? ?int after) {
?? ??? ??? ??? ?// TODO Auto-generated method stub
?? ??? ??? ??? ?Log.e("AAA", "==beforeTextChanged==s:"+s+"=start:"+start+"=count:"+count+"=after:"+after);
?? ??? ??? ??? ?
?? ??? ??? ?}
?? ??? ??? ?/**
?????? ??? ? * 改變文本之后調(diào)用
?????? ??? ? * Editable s:改變之后的文本
?????? ??? ? */
?? ??? ??? ?@Override
?? ??? ??? ?public void afterTextChanged(Editable s) {
?? ??? ??? ??? ?// TODO Auto-generated method stub
?? ??? ??? ??? ?Log.e("AAA", "==afterTextChanged==s:"+s);
?? ??? ??? ?}
?? ??? ?});
?? ?
?? ?/**
???????? * 08-25 15:23:44.334: E/AAA(12812): ==beforeTextChanged==s:=start:0=count:0=after:1
?? ??? ??? ?08-25 15:23:44.334: E/AAA(12812): ==onTextChanged==s:g=start:0=before:0=count:1
?? ??? ??? ?08-25 15:23:44.334: E/AAA(12812): ==afterTextChanged==s:g
?? ??? ??? ?08-25 15:23:45.904: E/AAA(12812): ==beforeTextChanged==s:g=start:1=count:0=after:1
?? ??? ??? ?08-25 15:23:45.904: E/AAA(12812): ==onTextChanged==s:gh=start:1=before:0=count:1
?? ??? ??? ?08-25 15:23:45.904: E/AAA(12812): ==afterTextChanged==s:gh
?? ??? ??? ?08-25 15:23:47.824: E/AAA(12812): ==beforeTextChanged==s:gh=start:2=count:0=after:1
?? ??? ??? ?08-25 15:23:47.824: E/AAA(12812): ==onTextChanged==s:ghj=start:2=before:0=count:1
?? ??? ??? ?08-25 15:23:47.824: E/AAA(12812): ==afterTextChanged==s:ghj
?? ??? ??? ?08-25 15:23:49.164: E/AAA(12812): ==beforeTextChanged==s:ghj=start:2=count:1=after:0
?? ??? ??? ?08-25 15:23:49.164: E/AAA(12812): ==onTextChanged==s:gh=start:2=before:1=count:0
?? ??? ??? ?08-25 15:23:49.164: E/AAA(12812): ==afterTextChanged==s:gh
?? ??? ??? ?08-25 15:23:49.694: E/AAA(12812): ==beforeTextChanged==s:gh=start:1=count:1=after:0
?? ??? ??? ?08-25 15:23:49.694: E/AAA(12812): ==onTextChanged==s:g=start:1=before:1=count:0
?? ??? ??? ?08-25 15:23:49.694: E/AAA(12812): ==afterTextChanged==s:g
???????? */
總結(jié)
- 上一篇: python爬虫笔记(八) 实例3:用P
- 下一篇: 奇迹虚拟服务器,奇迹服务器ADSL mo