0
두 개의 단추와 조각으로 구성된보기가 있습니다. button1을 누르면 조각 하나 (텍스트보기)가 표시됩니다. 버튼 2를 누르면 조각 2 (텍스트보기)가 표시됩니다. 문제는 단편 중 하나만 보여 주길 바랍니다. 버튼을 앞뒤로 누르면 프래그먼트 1과 프래그먼트 1 사이가 전환됩니다.하나를 표시하려고 할 때 두 개의 조각 표시
왜 그럴까요? 하나의 조각 만 표시되도록이 문제를 어떻게 해결할 수 있습니까? 당신은 XML 레이아웃을 통해 지정된 조각을 대체 할 수
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Fragment No.1"
android:onClick="selectFrag" />
<Button
android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="selectFrag"
android:text="Fragment No.2" />
<fragment
android:name="com.example.fragmentstest.FragmentOne"
android:id="@+id/fragment_place"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>