日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

04 高级控件总结

發(fā)布時(shí)間:2024/3/26 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 04 高级控件总结 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1,Spinner
?? ?>概念;下拉菜單控件 默認(rèn)顯示當(dāng)前選擇的項(xiàng)(第一次展示集合中第一條數(shù)據(jù))
?? ?>屬性:
?? ??? ?android:entries="@array/books"? 展示數(shù)據(jù)? (note:提前知道數(shù)據(jù)是什么 )
?? ????? android:spinnerMode="dropdown" spinner 樣式
?? ????? dropdown:下拉列表???? 設(shè)置popupBackground? 每一項(xiàng)的背景顏色
?? ????? 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上

?? ?>如果三個(gè)參數(shù)的ArrayAdapter?? item布局的根節(jié)點(diǎn) 必須是TextView
???????? 如果跟節(jié)點(diǎn)不是TextVIew 三個(gè)參數(shù)的會報(bào)錯(cuò)????? 使用四個(gè)參數(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(文本輸入框)

?? ?> 默認(rèn)輸入倆個(gè)字符? 才開始索引
????????? android:completionThreshold="1" 輸入幾個(gè)字符開始索引
?? ??? ?
6,addTextChangedListener()的用法?

?? ?>
?? ?
?????? ?
??????? //文本發(fā)生變化的監(jiān)聽?? 可以對EditText操作 ?
??????? autoView.addTextChangedListener(new TextWatcher() {
?? ??? ??? ?
?????? ??? ?/**
?????? ??? ? * 改變文本時(shí)調(diào)用
?????? ??? ? * CharSequence s:變化之后的文本
?????? ??? ? * int start:變化的起點(diǎn)? 從哪里開始改變
?????? ??? ? * 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?? 刪除是改變:刪除幾個(gè)展示結(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é)

以上是生活随笔為你收集整理的04 高级控件总结的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。