我创建了2个Horizontal recycleView.这是完美的.我需要在每个recycleView中的项目之间拖放功能,以及在这两个recycleView项目之间拖放.我现在还做了什么 –
private RecyclerView mRecyclerViewCompletedTask; private RecyclerView.Adapter mAdapterCompletedTask; private RecyclerView.LayoutManager mLayoutManagerCompletedTask; private static String LOG_TAG = "RecyclerViewActivity"; private RecyclerView mRecyclerViewInCompleteTask; private RecyclerView.Adapter mAdapterInCompleteTask; private RecyclerView.LayoutManager mLayoutManagerInCompleteTask; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main2); mRecyclerViewCompletedTask = (RecyclerView) findViewById(R.id.my_recycler_view_completed_task); mRecyclerViewCompletedTask.setHasFixedSize(true); mLayoutManagerCompletedTask = new LinearLayoutManager(this); mRecyclerViewCompletedTask.setLayoutManager(mLayoutManagerCompletedTask); mAdapterCompletedTask = new MyRecyclerViewAdapterCompletedTask(getDataSet()); mRecyclerViewCompletedTask.setAdapter(mAdapterCompletedTask); LinearLayoutManager layoutManager1 = new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false); mRecyclerViewCompletedTask.setLayoutManager(layoutManager1); mRecyclerViewInCompleteTask = (RecyclerView) findViewById(R.id.my_recycler_view_incomplete_task); mRecyclerViewInCompleteTask.setHasFixedSize(true); mLayoutManagerInCompleteTask = new LinearLayoutManager(this); mRecyclerViewInCompleteTask.setLayoutManager(mLayoutManagerInCompleteTask); mAdapterInCompleteTask = new MyRecyclerViewAdapterInCompleteTask(getDataSet()); mRecyclerViewInCompleteTask.setAdapter(mAdapterInCompleteTask); LinearLayoutManager layoutManager2 = new LinearLayoutManager(this,false); mRecyclerViewInCompleteTask.setLayoutManager(layoutManager2); } @Override protected void onResume() { super.onResume(); ((MyRecyclerViewAdapterCompletedTask) mAdapterCompletedTask).setOnItemClickListener(new MyRecyclerViewAdapterCompletedTask.MyClickListener() { @Override public void onItemClick(int position,View v) { Log.i(LOG_TAG," Clicked on Item " + position); } }); ((MyRecyclerViewAdapterInCompleteTask) mAdapterInCompleteTask).setOnItemClickListener(new MyRecyclerViewAdapterInCompleteTask.MyClickListener() { @Override public void onItemClick(int position," Clicked on Item " + position); } }); } private ArrayList<DataObject> getDataSet() { ArrayList results = new ArrayList<DataObject>(); for (int index = 0; index < 20; index++) { DataObject obj = new DataObject("Some Primary Text " + index,"Secondary " + index); results.add(index,obj); } return results; }
自定义这个库,得到了我想要的东西.链接 – https://github.com/woxblom/DragListView
解决方法
如果您仍然对一个简单的解决方案
see my code on GitHub感兴趣.它展示了如何在两个RecyclerViews之间拖放.