2012-09-01 83 views
0

是什麼問題? 我如何膨脹佈局包含片段? 我不知道錯誤信息的含義。 請幫幫我。 謝謝android充氣佈局包含片段

錯誤消息

09-01 18:44:58.698: E/AndroidRuntime(20617): Caused by: 
java.lang.IllegalArgumentException: Binary XML file line #7: Duplicate id 0x7f080002, 
tag null, or parent id 0x0 with another fragment for com.example.testing.ListFragment 

我的代碼

public static class DummySectionFragment extends Fragment { 
    public DummySectionFragment() { 
    } 

    public static final String ARG_SECTION_NUMBER = "section_number"; 

    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
      Bundle savedInstanceState) { 
     Log.e("555", "hello"); 
     return inflater.inflate(R.layout.main, null); 

     /* 
     TextView textView = new TextView(getActivity()); 
     textView.setGravity(Gravity.CENTER); 
     Bundle args = getArguments(); 
     textView.setText(Integer.toString(args.getInt(ARG_SECTION_NUMBER))); 
     return textView;*/ 
    } 
} 

main.xml中

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="horizontal" > 

    <fragment 
     android:id="@+id/listFragment" 
     android:layout_width="150dip" 
     android:layout_height="match_parent" 
     android:layout_marginTop="?android:attr/actionBarSize" 
     class="com.example.testing.ListFragment" ></fragment> 

    <fragment 
     android:id="@+id/detailFragment" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     class="com.example.testing.DetailFragment" > 
     <!-- Preview: [email protected]/details --> 
    </fragment> 

</LinearLayout> 

糟糕!您的問題無法提交,因爲:

您的帖子沒有太多的上下文來解釋代碼段;請更清楚地解釋你的情況。

回答

1

在另一個Fragment的內部不能有Fragment