반응형

리스트뷰 내의 아이템의 view 조합이

  1. 리스트뷰 + 아이템 내의 객체가 버튼(Button)을 포함할 때
  2. 리스트뷰 + 아이템 내의 객체가 체크박스(CheckBox)를 포함할 때
  3. 리스트뷰 + 아이템 내의 객체가 이미지 버튼(ImageButton)을 포함할 때

위의 3가지 경우에서는 아이템에서 포커스(Focus)를 가져가기 때문에 클릭이 먹히지 않는다. 



해결방법

1번과 2번의 경우) xml 파일안에서 해당 객체에 속성 추가

android:focusable="true"        -- 포커스를 주고 싶을 경우, true 그렇지 않을 경우 false 처리

android:clickable="true"        

android:focusableInTouchMode="true"


3번의 경우) java 소스 안에서 해당 객체 옵션 추가

(이미지 버튼 객체).requestFocus();

(이미지 버튼 객체).setFocusable(boolean값);


커스텀 리스트뷰에서 아이템을 클릭시, 상세화면으로 넘어가고!

버튼을 클릭시 즐겨찾기가 되게 하고 싶어서 focusable를 true로 모두 주고 나서 문제 해결

<ToggleButton

    android:id="@+id/favorite"

    android:layout_height="wrap_content"

    android:layout_width="wrap_content"

    android:layout_weight="0.3"

    android:src="@drawable/favorite_stat"

    android:focusable="true"

    android:clickable="true"

    android:focusableInTouchMode="true"/>



참고 링크

  • http://jwandroid.tistory.com/218


반응형

+ Recent posts