Android的膨胀的布局包含片段 [英] android inflate a layout contains fragment
本文介绍了Android的膨胀的布局包含片段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是什么问题? 我怎么能膨胀的布局包含片段? 我不知道该错误信息的含义。 请帮我。 谢谢
what is the problem? how can i inflate a layout contains fragment? i dont know the meaning of the error message. Please help me. Thank you
错误信息
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
我的code
My Code
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中
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: layout=@layout/details -->
</fragment>
</LinearLayout>
哎呀!你的问题不能提交,因为:
Oops! Your question couldn't be submitted because:
您的文章没有太多的上下文来解释code段;请更清楚地解释您的方案。
Your post does not have much context to explain the code sections; please explain your scenario more clearly.
推荐答案
您不能有一个片段
在另一个片段
。
You can not have a Fragment
inside another Fragment
.
这篇关于Android的膨胀的布局包含片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文