ListView滾動條問題

android:scrollbarTrackVertical="@drawable/bar_bg" //ListView滾動條背景
android:scrollbarThumbVertical="@drawable/listview_bar" //ListView滾動條滑塊

//更換快速滑動圖片 需設置ListView屬性android:fastScrollEnabled="true"

list = (ListView)this.findViewById(R.id.mylist);
        try {
Field f = AbsListView.class.getDeclaredField("mFastScroller");
if(!f.isAccessible()){
f.setAccessible(true);
}
Object o = f.get(list);
f = f.getType().getDeclaredField("mThumbDrawable");
f.setAccessible(true);
Drawable drawable=(Drawable) f.get(o);
drawable = getResources().getDrawable(R.drawable.icon);
f.set(o,drawable);

} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
相關文章
相關標籤/搜索