2011-05-02 78 views
0

我的英语很差,如果您不明白我的意思,请告诉我,谢谢。android setVisibility ui显示奇怪

我的数据存储在SQLiteDatabase中,我使用listview来显示我的data.and我通过ListActivity.onItemClick()实现了collapse/expand自己。但是当childview.setVisibility(View.GONE),有时android ui显示一半,我是堆栈溢出的新用户,并且我无法发布图像。

1)默认显示:扩大各组

的图像链接到另一个网站,

2)collapsed all groups

3)when several times clicked on listview's item,the main activity showed only half of window height

这有什么错我的解决方案。或者它的android bug?

这是代码:

@Override 
    public void onListItemClick(ListView list,View v,int position,long id) { 
     if(v instanceof RelativeLayout) { 
      ViewGroup group = (ViewGroup)v; 
      ImageView groupIndicator = (ImageView) group.getChildAt(0); 
      TextView itemContentView = (TextView) group.getChildAt(2); 
      if(itemContentView.getVisibility() == View.GONE) { 
       groupIndicator.setBackgroundResource(R.drawable.expand); 
       itemContentView.setVisibility(View.VISIBLE); 
      } else { 
       groupIndicator.setBackgroundResource(R.drawable.collapse); 
       itemContentView.setVisibility(View.GONE); 
      } 
     } 
    } 

这是ListView控件的布局XML。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:background="@drawable/corner" 
    android:padding="3dip" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <ImageView android:id="@+id/groupIndicator" android:background="@drawable/expand" android:layout_width="wrap_content" android:layout_height="wrap_content"/> 
    <TextView android:id="@+id/rowTitle" android:paddingLeft="5dip" android:textColor="#FFFFFF" android:textStyle="bold" android:layout_toRightOf="@id/groupIndicator" android:layout_width="wrap_content" android:layout_height="wrap_content"/> 
    <TextView android:id="@+id/rowContent" android:layout_below="@id/groupIndicator" android:padding="5dip" android:layout_width="fill_parent" android:layout_height="wrap_content"/> 
</RelativeLayout> 

回答