ghostbust555 ghostbust555 - 21 days ago 8
Android Question

How to do fastScrolling on tablelayout in Android

I have tableLayout filled with a lot of rows (in xml). I wrapped it in a scrollView and it scrolls great. However I'm trying to get the fastScrolling feature to work (the slider bar on the right) and saying

android:fastScrollEnabled="true"
for both the tableLayout and the scrollView does nothing. Does anyone know how to fix this?

Here is a simplified version of the layout code

<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/frameLayout"
android:layout_width="match_parent" android:layout_height="wrap_content">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/tableLayoutParent">
<TableLayout android:id="@+id/tableLayout" android:fastScrollEnabled="true" android:layout_width="fill_parent" android:layout_height="fill_parent">
<TableRow android:layout_width="match_parent" android:layout_height="wrap_content">
<Button
android:text="◦"
android:id="@+id/spaceColumn"
android:background="@drawable/top_button"
android:clickable="true"
android:onClick="showSlider"
android:gravity="center"
android:padding="2dip"
android:textSize="15px"
android:layout_height="wrap_content"
android:layout_width="15dip"/>
<ToggleButton
android:textOn="Title ▼"
android:textOff="Title"
android:id="@+id/titleColumn"
android:background="@drawable/top_button"
android:clickable="true"
android:onClick="sortSong"
android:gravity="center"
android:padding="2dip"
android:textSize="15px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="0dip"/>
<ToggleButton
android:textOn="Artist ▼"
android:textOff="Artist"
android:id="@+id/artistColumn"
android:background="@drawable/top_button"
android:clickable="true"
android:onClick="sortArtist"
android:gravity="center"
android:padding="2dip"
android:textSize="15px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="0dip"/>
<ToggleButton
android:textOn="Time ▼"
android:textOff="Time"
android:id="@+id/timeColumn"
android:background="@drawable/top_button"
android:clickable="true"
android:onClick="sortTime"
android:gravity="center"
android:padding="2dip"
android:textSize="15px"
android:layout_height="wrap_content"
android:layout_width="45dip"/>
<ToggleButton
android:textOn="Album ▼"
android:textOff="Album"
android:id="@+id/albumColumn"
android:background="@drawable/top_button"
android:clickable="true"
android:onClick="sortAlbum"
android:gravity="center"
android:padding="2dip"
android:textSize="15px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="0dip"/>
</TableRow>
</TableLayout>
</ScrollView>
</FrameLayout>


song data is then read from a SQLite database and filled into the table layout

Answer

ScrollView doesn't support fast scroll out of the box as far as I know, what you are looking for is ListView.

Edit: Unless you implement it yourself ofcourse.