2013-05-02 63 views
0

在我的ListView(使用库Android Amazing Listview)中,我有2个部分,我想隐藏第1部分的标题。我删除标题的部分Android惊人的列表视图

view.findViewById(R.id.header).setVisibility(View.GONE); 

试图在bindSectionHeader()但它并不隐藏标题,而是它只是让它动了我行。

那么,有没有办法隐藏第一节的节标题?我需要的只是显示第2部分的标题(使其始终可见)。任何帮助是极大的赞赏。

ListView项目XML:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <include 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     layout="@layout/product_section_header" 
     android:background="@android:color/white" /> 

    <TextView 
     android:id="@+id/tv_title" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/screen11_low_opacity" 
     android:gravity="center" 
     android:text="TextView" 
     android:textColor="@android:color/black" 
     android:textStyle="bold" /> 

    <ImageView 
     android:id="@+id/iv_image" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_horizontal" 
     android:src="@drawable/stub" /> 

</LinearLayout> 

头XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/header" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center" 
    android:orientation="horizontal" > 

    <ImageButton 
     android:id="@+id/button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@android:color/transparent" 
     android:src="@drawable/screen11_flag" /> 
</LinearLayout> 
+0

CON您提供一些示例xml布局? – donfede 2013-05-02 05:22:14

+0

是的,你应该分享你的代码.....你可以尝试设置标题的高度为零... – 2013-05-02 05:22:59

+0

添加XML。 @Pankaj Kumar,我认为它不会有帮助,因为'View.GONE'也是。我仍然会放弃它。也许它有帮助。 – Sufian 2013-05-02 05:35:54

回答

0

Android Amazing Listview玩弄后,我能塑造它来满足我的要求。因此,这里是我做过什么......

configurePinnedHeader(),隐藏覆盖标题:

if(getSectionForPosition(position)==0){ //hide header 
    lSectionHeader.setText(""); 
    lSectionHeader.setBackgroundColor(Color.TRANSPARENT); 
} 
//in else block, you have to set the background (when you are setting the text) 

bindSectionHeader(),隐藏我们的细胞所附加的标题:

if(getSectionForPosition(position)==0){ 
    TextView lSectionTitle = (TextView) view.findViewById(R.id.header); 
    lSectionTitle.findViewById(R.id.header).setVisibility(View.GONE); 
} 
相关问题