2014-11-08 2 views
0

나는 많은 활동을하는 실행중인 앱이 있습니다. 현재 버튼과 onclick 이벤트 관련 활동이 열려 있습니다. 이제는 새로운 navigationdrawer 활동 [android eclipse에서 제공]을 만들고 서랍 목록 메뉴의 모든 버튼 옵션을 나열했습니다. 이제 목록 메뉴 선택을 클릭하여 내 활동을 호출하고 싶습니다. 나는 많은 솔루션을 시도했지만 구현하지 못했습니다.navigationdrawer 만들기 및 이전 활동 호출

내 활동을 호출하기위한 코드를 작성한 함수가 무엇인지 알려주는 사람이 있습니까? 그것은 onSectionAttached()인가? Intent ..를 시도하고 avtivity를 시작하면 새로운 활동이로드되고 탐색 서랍은 비활성화됩니다.

새로운 조각 클래스를 만들어야합니까?

답변

0

두 가지 옵션이있는 것 같습니다. 인 텐트를 사용하고 두 번째 활동에서 서랍을 구현할 수 있습니다. 이로 인해 많은 코드가 중복되기 때문에 이상적이지 않습니다.

또는 (더 나은)

당신은 당신의 활동에 다른 레이아웃을 사용할 수 있습니다. 다음과 같은 내용이 있습니다.

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <FrameLayout 
     android:id="@+id/frame_container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

    <ListView 
     android:id="@+id/list_slidermenu" 
     android:layout_width="240dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:choiceMode="singleChoice" 
     android:dividerHeight="1dp" /> 

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

그런 다음 framelayout에서 조각을 사용할 수 있습니다. 그런 다음 fragmentmanager를 사용하고 사용자가 서랍에서 클릭하는 프레임의 조각을 바꿉니다.

자세한 내용은 http://developer.android.com/training/implementing-navigation/nav-drawer.html을 확인하십시오.