问题是什么?我如何膨胀包含片段的布局?我不知道错误消息的含义。请帮我。谢谢
错误消息
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;*/
}
}
主要的.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: layout=@layout/details -->
</fragment>
</LinearLayout>
哎呀!您的问题无法提交,因为:
您的帖子没有太多上下文来解释代码部分;请更清楚地解释您的情况。