我想看看下面的拇指滚动条:Android的ListView的拇指滚动条
http://www.androidpatterns.com/uap_pattern/scroll-thumb
我所看到的是:
我的XML布局是:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="xxaassss"
ads:loadAdOnCreate="true" >
</com.google.ads.AdView>
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:divider="#b5b5b5"
android:dividerHeight="1dp"
android:listSelector="@drawable/list_selector" />
</LinearLayout>
我的Java代码在Activity类中的onCreate(我从活动类,而不是ListActivity扩展):
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ListView list=(ListView)findViewById(R.id.list);
ArrayList<HashMap<String, String>> categoriesList = new ArrayList<HashMap<String, String>>();
for(int i=0;i<119;i++) {
HashMap<String, String> map = new HashMap<String, String>();
map.put(KEY_ID, String.valueOf(i));
//map.put(KEY_TITLE, "hello");
map.put(KEY_TITLE, Prayer.tip.getNthLine(i, true).replace("~", ""));
map.put(KEY_ARTIST, "");
map.put(KEY_DURATION, "");
map.put(KEY_THUMB_URL, String.valueOf(getResources().getIdentifier("img" + i, "drawable", getPackageName())));
categoriesList.add(map);
}
LazyAdapter adapter=new LazyAdapter(this, categoriesList);
list.setAdapter(adapter);
list.setFastScrollEnabled(true);
我没有贴LazyAdapter的代码,因为我认为这无关与那个快速的拇指滚动条的样式。如果需要,我也可以发布该代码。
http://stackoverflow.com/questions/3071068/change-scrollbar-color-in-android –
由于您在Android 4.0或更高版本上运行您的应用,因此您会看到滚动条缩略图。链接中的拇指来自Android 2.3。您可以从上面发布的链接@Brijesh获取该图片并使用它。 – Milan