I use a fragment activity to hold a list fragment which renders a bunch of products:
public class ProductsListActivity extends SherlockFragmentActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
setTheme(R.style.Sherlock___Theme);
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_products_list);
// setFastScrollEnabled(true) ?
}
}
...
<!-- fragment_products_list.xml -->
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.example.fragment.ProductsListFragment"
android:id="@+id/list_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
...
public class ProductsListFragment extends SherlockListFragment {
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
// setFastScrollEnabled(true) ?
super.onViewCreated(view, savedInstanceState);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
...
}
}
I want to enable fast scrolling for the list of products and found another post which describes how to do this for a list activity. But how can I activate fast scrolling for the fragment? It would be okay to define this in XML or via code.
The SherlockListFragment also has a
getListView()
method inherited from ListFragment.This is how it could look like inside your
ListFragment
: