首先把布局文件中李斯特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);
}
}
修改listview默认的滑动条
时间: 2024-10-16 06:08:27