본문 바로가기
Programming/Android

DrawerLayout 내의 listview

by 유주원 2014. 12. 24.

현재 Navigation Drawer의 개발을 위해 아래와 같이 코드를 작성하였다.


<android.support.v4.widget.DrawerLayout

android:id="@+id/drawer_layout"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".activity.HomeActivity">

<ListView 

android:id="@+id/left_drawer"

android:layout_width="70dp"

android:layout_height="match_parent"

android:layout_gravity="start"

android:choiceMode="singleChoice"

android:divider="@android:color/white"

android:dividerHeight="0dp"

android:background="@android:color/white" />

<FrameLayout

android:id="@+id/content_fragment"

android:layout_width="match_parent"

android:layout_height="0px"

android:layout_weight="2" />

</android.support.v4.widget.DrawerLayout>


위와 같이 작성하면 아래의 그림과 같은 UI 화면(왼쪽에 나타나는 customNavigation 화면)이 나타나고,

각각의 listView에 있는 아이템들을 클릭하면 각각의 fragment가 attach되는 프로그램이다.



그런데 listView의 setOnItemClickListener가 안먹는다....

왜이러지... 왜이러지...

ListView.onItemClickListener로도 해보고 AdapterView.onItemClickListener로도 해보고.. stackOverflow에서도

찾아봤는데 해결한 사람이 없는 것 같다.

어떤 사람은 프로젝트 지우고 다시 했더니 된다고 한 사람도 있는데..

차마 이렇게 까지 하긴 싫었고..

그런데..

혹시나 해서 위의 xml 코드부분에서 <ListView>와 <FrameLayout>의 위치를 바꾸어 주었다.

그랬더니.. 이벤트가 먹는다....

원인은 찾지 못했지만 혹시 나같은 문제에 봉착했을 개발자들을 위해 이렇게 이력을 남긴다.