Limepen 개발 블로그

안드로이드의 각 뷰별 여러 이벤트 동작하게 구현하기 본문

모바일/Android

안드로이드의 각 뷰별 여러 이벤트 동작하게 구현하기

LimeCode 2014. 12. 31. 13:35


여러 이벤트를 동시에 구현하는것은 그리 어려운 방법은 아니죠.

하지만 뷰가 중첩(nested)되어 있을 경우에 한가지만 이벤트가 정상동작하고 나머지는 제대로 동작하지 않는 경우가 발생할 수 있어요

여러가지 방법이 있겠지만 그중 간단한 한가지를 소개할께요


The trick to overcome this design issue consists of removing the focusability property of all itemview’s descendants. You can obviously do this by adding android:focusable="false" on all of your controls but the preferred, clearest and easiest way to do is to block focusability from the itemview root ViewGroup. Focusability can be blocked using the android:descendantFocusability XML attribute:

참고: http://cyrilmottier.com/2011/11/23/listview-tips-tricks-4-add-several-clickable-areas/


이벤트가 필요한 자식뷰에 android:focusable="false"를 추가하고 부모뷰에 android:descendantFocusability="blocksDescendants" 를 추가해주세요









Comments