修改listview默认的滑动条
2014-05-13 15:18
225 查看
首先把布局文件中李斯特view添加android:fastScrollEnabled="true";
然后代码中添加代码:
private void setScrollBar()
{
try
{
Field f = AbsListView.class.getDeclaredField("mFastScroller");
f.setAccessible(true);
Object o = f.get(listview);
f = f.getType().getDeclaredField("mThumbDrawable");
f.setAccessible(true);
Drawable drawable = (Drawable) f.get(o);
drawable = getResources().getDrawable(R.drawable.ic_launcher);
f.set(o, drawable);
} catch (Exception e)
{
throw new RuntimeException(e);
}
}
然后代码中添加代码:
private void setScrollBar()
{
try
{
Field f = AbsListView.class.getDeclaredField("mFastScroller");
f.setAccessible(true);
Object o = f.get(listview);
f = f.getType().getDeclaredField("mThumbDrawable");
f.setAccessible(true);
Drawable drawable = (Drawable) f.get(o);
drawable = getResources().getDrawable(R.drawable.ic_launcher);
f.set(o, drawable);
} catch (Exception e)
{
throw new RuntimeException(e);
}
}
相关文章推荐
- android开发之修改ListView默认滑动条样式
- ViewPager切换Page之修改默认滑动偏移量
- 基于ListView的滑动删除、添加、修改
- android 取消listview的默认滑动到顶的效果
- GridView、ListView默认的点击背景修改
- Android 解决ListView初始化时默认滑动到底部问题
- Android之ListView优化(使用Lrucache,图片滑动时使用默认图片,停止时加载)
- listview修改滑动块图标
- 修改安卓5.0listView无法滑动的波浪提示色
- Android之ListView优化(使用Lrucache,图片滑动时使用默认图片,停止时加载)
- ListView去掉或者修改默认点击背景
- 修改listView默认滚动条的方法
- ListView 滑动的时候 变系统默认黑色,或是设置不变色
- ListView,去item之间的黑线,去滑动背影,去默认的点击黄色背景
- ViewPager 修改默认滑动偏移量
- Android之ListView优化(使用Lrucache,图片滑动时使用默认图片,停止时加载)
- ListView 滑动的时候 变系统默认黑色,或是设置不变色
- Android之ListView优化(使用Lrucache,图片滑动时使用默认图片,停止时加载)
- (原创)使用AsyncTask(带修改线程池方式)+自定义ImageLoader+LRU算法对图片三级缓存及其显示优化(只有在ListView滑动停止的时候才去网络请求获取图片数据)
- listview 修改快速滑动的图片