I have a class that extends ListFragment. I want to add a fixed header.
I tried this way:
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
View mHeaderView = getActivity().getLayoutInflater().inflate(R.layout.remedy_header_view, null);
getListView().addHeaderView(mHeaderView);
if (mAdapter == null) {
int layout = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ? android.R.layout.simple_list_item_activated_1: android.R.layout.simple_list_item_1;
mAdapter = new SimpleCursorAdapter(getActivity(), layout, null, new String[] { ClinicalTip.Remedies.COLUMN_NAME_REMEDY_NAME }, new int[] { android.R.id.text1 }, 0);
}
setListAdapter(mAdapter);
setListShown(false);
Activity().getSupportLoaderManager().initLoader(0, null, this);
}
@Override
public void onDestroyView() {
// TODO Auto-generated method stub
super.onDestroyView();
setListAdapter(null);
}
But using this way, the header is not fixed, it gets scrolled. What could be the solution for adding fixed header in ListFragment?