我试图做同样的片段,但我有这个错误。我该怎么做才能解决这个错误?
Caused by: java.lang.IllegalArgumentException: Binary XML file line #117: Duplicate id 0x7f080072, tag null, or parent id 0x0 with another fragment for com.google.android.gms.maps.SupportMapFragment
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:296)
我看到有相同问题的帖子:Duplicate ID, tag null, or parent id with another fragment for com.google.android.gms.maps.MapFragment和duplicated id with fragment,但他们没有帮助我。
修改
一些代码
for (Task task : tasks.getTaskList()) {
Fragment targetFragment = TargetFragment.getInstance(task);
fragmentList.add(targetFragment);
}
viewPager.setAdapter(new TargetAdapter(context.getSupportFragmentManager(),
fragmentList));
pageIndicator.setViewPager(viewPager);