1.android:fastScrollEnabled="true"

2.Listview组件没有提供修改快速滑块的图像的API,因此不能直接修改,需要用java的反射技术修改

listView1 = (ListView)findViewById(R.id.listView1);
		listView1.setFastScrollEnabled(true);
		//获取FastScroller对象
		try {
			Field field = AbsListView.class.getDeclaredField("mFastScroller");
			field.setAccessible(true);
			Object obj = field.get(listView1);
			//获取FastScroller.mThumbDrable变量的Field对象
			field = field.getType().getDeclaredField("mThumbDrawable");
			field.setAccessible(true);
			//获取FastScroller.mThumbDrable的值
			Drawable drawable = (Drawable)field.get(obj);
			drawable = getResources().getDrawable(R.drawable.ic_launcher);
			field.set(obj, drawable);
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

运行效果:


posted on 2013-05-13 18:33  纯洁的坏蛋  阅读(136)  评论(0编辑  收藏  举报