ListView詳解

1、android ListView詳解

2、Android中ListView的性能問題
3、設置背景色爲透明,防止滑動時,背景變黑
android:cacheColorHint="#00000000"
4、設置ListView控件條目被按下時背景顏色在文字背後,設置成True時背景色會覆蓋文字
android:drawSelectorOnTop="false" 
5、android:divider屬性:本屬性設置listView中的選項分隔符,可設置圖片,顏色等。
android:divider="#00000000" 設置爲無色,這樣顯示時,就沒有分隔線了。
6、android:minHeight="?android:attr/listPreferredItemHeight" 設置最小高度由item決定
7、Listview更新:
    在BaseAdapter的getView()方法中根據條件改變View的字體顏色、其中的圖片等,是不能立即在UI上顯示的,必須調用notifyDataSetChanged()方法,實現更新。
    ListView不能局部更新(現在爲止我沒找到實現局部更新的方法,如有同學有方法實現局部更新,盼賜教。),更新實現如下:
    BaseAdapter adapter = new BaseAdapter();
    adapter.notifyDataSetChanged();
8、更改ListView中選中框的TextView的字體顏色:
    要改變TextView的顏色,需調用TextView的setTextColor()方法設置,在使用中發現,在BaseAdapter中的getView()中使用“name.setTextColor(R.color.background);”方式字體會是黑色,可用”name.setTextColor(Color.rgb(0, 234, 255));“方式改變字體顏色,“Color.rgb(0, 234, 255)”爲要設置的顏色的RGB值;最後在OnItemSelectedListener的onItemSelected()方法中調用”adapter.notifyDataSetChanged();“方法即可。
    雖然這種方式可以改變字體顏色,但不知道爲什麼?盼有知道的同學解惑。
9、可擴展的ListView:ExpandableListView
    ExpandableListView爲ListView子類,
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章