2013-06-03 51 views

回答

0

in getHeaderView - set HeaderView.Visibility(View.GONE);

0

我有同样的问题。 header.setVisibility(View.GONE)不起作用。

解决办法是:

布局头视图必须与layout_height = “WRAP_CONTENT”

,然后,此布局的内容,可以setVisibility(View.GONE)

0

我用相同适配器两个布局

布局与头

<se.emilsjolander.stickylistheaders.StickyListHeadersListView 
android:id="@+id/listview" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:background="@android:color/white" /> 

布局而不头

<ListView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/listview" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

onCreateView:上任务结果

if (needHeader) { 
    mainView = inflater.inflate(R.layout.ly_list_with_header, null); 
    stickyListHeadersListView = (StickyListHeadersListView) mainView.findViewById(R.id.listview); 
} else { 
    mainView = inflater.inflate(R.layout.ly_without_header, null); 
    listView = (ListView) mainView.findViewById(R.id.listview); 
} 

if (needHeader) { 
    stickyListHeadersListView.setAdapter(adapter); 
} else { 
    listView.setAdapter(adapter); 
}