将片段添加到回收站视图项

时间:2016-09-12 16:42:55

标签: android listview android-fragments android-recyclerview

参考这些

Can a ListView contain Fragments

Add fragment into listview item

我尝试使用以下代码创建Recycler视图项:

 SingleImageViewFragment fragment = new SingleImageViewFragment();
 FrameLayout layout = new FrameLayout(getActivity(context));
 int id = View.generateViewId();
 layout.setId(id);
 getActivity(context).getSupportFragmentManager().beginTransaction().replace(layout.getId(), fragment)
.commit();// **this line causing problem**
return layout;
  • 以上代码用于初始化回收者视图持有者。

但得到以下错误:

  

android.content.res.Resources $ NotFoundException:无法找到   资源ID#0x1                                                                                          在android.content.res.Resources.getResourceName(Resources.java:3014)                                                                                          在   android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1059)

我正在使用带有LinearLayoutManager的Recycler视图。

0 个答案:

没有答案