2012-03-03 5 views
3

조각을 사용하여 3.0 용 앱을 제작하려고합니다. 응용 프로그램의 왼쪽에는 정적 조각이 있고 오른쪽에는 동적 조각이 있습니다. 동적 인 부분의 각 조각에는 제목이 있습니다. 초기 조각을 대체 할 때마다 첫 번째 제목은 첫 번째 제목의 제목 위에 계속 표시됩니다. 후속 교체는 하단 부분을 대체하지만 초기 제목은 여전히 ​​표시됩니다 (미안하지만 아직 이미지를 게시 할 수 없습니다).Android 조각이 제대로 대체되지 않음

나는 영상을 위해 할 수있는 최저 :

초기 헤더

새로운 헤더

컨텐츠 (미세 디스플레이)

는 main.xml에 :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" > 
    <fragment 
     android:id="@+id/static_fragment" 
     android:name="ruleout.android.History_Fragment" 
     android:layout_width="500dp" 
     android:layout_height="match_parent" /> 
    <fragment 
     android:id="@+id/dynamic_fragment" 
     android:name="ruleout.android.New_Screen_Fragment" 
     android:layout_width="fill_parent" 
     android:layout_height="match_parent" /> 
</LinearLayout> 

부분 MainActivity 사용 조각 바꾸기

private void open(Fragment toShow) 
{ 
    FragmentTransaction fragmentTransaction = FragMag.beginTransaction(); 
    fragmentTransaction.replace(R.id.dynamic_fragment, toShow); 
    fragmentTransaction.addToBackStack(null); 
    fragmentTransaction.commit(); 
} 

추가 정보가 필요하면 도움을 위해 미리 알려 주시기 바랍니다.

답변

8

조각을 동적으로 변경하려면 레이아웃에서 선언 할 수 없습니다. Fragment documentation에는 내가 설명하는 것처럼 보이고있는 예제가 있습니다. 여기에는 레이아웃에 정적 조각이 선언되어 있고 동적으로 추가되고 대체 될 Fragment를 유지하는 FrameLayout이 있습니다.

+0

도움 주셔서 감사합니다. 그것은 위대한 작품. – cren90

관련 문제