2012-01-28 2 views
0

하나의리스트 뷰가 포함 된 활동이 있습니다. 이리스트 뷰는 비트 맵과 체크 박스가있는 relativeLayout을 표시하며 비트 맵을 사용할 수없는 경우 텍스트가 표시됩니다.안드로이드 : 포함되어있는 체크 박스를 클릭하면리스트 뷰의 행 높이가 변경됩니다.

내 문제는 비트 맵을 포함하지 않는 행입니다. 나는 체크 박스에

<?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" > 

    <ListView 
     android:id="@+id/myListView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:divider="@drawable/gradient_divider" 
     android:dividerHeight="1dp" /> 
</LinearLayout> 

row.xml

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

    <ImageView 
     android:id="@+id/banner" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_centerVertical="true" 
     android:adjustViewBounds="true" 
     android:layout_toLeftOf="@+id/registrationCheckBox" 
     android:filter="true" > 
    </ImageView> 

    <TextView 
     android:id="@+id/name" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:layout_centerVertical="true" 
     android:layout_gravity="left" 
     android:paddingLeft="5dp" 
     android:layout_toLeftOf="@+id/registrationCheckBox" > 
    </TextView> 

    <CheckBox 
     android:id="@+id/registrationCheckBox" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true"  
     android:layout_centerVertical="true" 
     android:clickable="false" 
     android:focusable="false" 
     android:paddingRight="5dp" > 
    </CheckBox> 

</RelativeLayout> 

, 행 변경의 높이 (확인란이 선택되어 증가, 선택하지 않은 드 주름)

activity.xml을 클릭하면 내 액티비티 코드

public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity); 

     hideActionBar(); 

     // init the controls 
     initControls(); 

     // populate the listView 
     this.adapter = new RegistrationAdapter(this, refreshContent());  
     this.listView.setAdapter(this.adapter); 

     this.listView.setItemsCanFocus(false); 
     this.listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); 
     this.listView.setOnItemClickListener(
      new ListView.OnItemClickListener() { 
        @Override 
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 
         ViewHolder viewHolder = (ViewHolder) view.getTag(); 

... 
        } 
      } 
    ); 

    } 

클릭하면 행 높이가 변경되는 것을 방지하는 방법에 대한 아이디어가 있습니다. 확인란?

답변

1

이 코드의 중요한 부분이 누락되어 있다고 생각합니다. 어댑터 코드입니다.

비트 맵과 텍스트 간의 전환은 어떻게 처리합니까?

+0

당신은 완전히 옳습니다! 방금 ​​사용하고있는 것을 보았습니다. banner.setVisibility (hide? View.VISIBLE : View.INVISIBLE); View.GONE보다는 배너를 숨기기 ... Viewing으로 전환하기 .Gone은 트릭을했습니다 ... 힌트를 주셔서 감사합니다! – user1026605

0

아마도 ImageView를 고정 된 높이 (실제 이미지에 맞을 정도로 충분히 큼)로 설정하거나 표시 할 실제 이미지가 없을 때 더미 보이지 않는 이미지를 제공하십시오.

관련 문제