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();
}

相关文章
相关标签/搜索