本文介绍了在两个回收视图之间拖放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了 2 个 Horizontal recycleView.这是完美的工作.我需要在每个 recycleView 内的项目之间进行拖放以及在这两个 recycleView 的项目之间进行拖放的功能.我现在还在做的 -
I have created 2 Horizontal recycleView. Which is working perfectly. I need the functionality of drag and drop between item inside each recycleView as well as drag and drop between those two recycleView's item. What I did still now -
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, LinearLayoutManager.HORIZONTAL, 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, View v) {
Log.i(LOG_TAG, " 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
推荐答案
如果您仍然对一个简单的解决方案感兴趣 参见我在 GitHub 上的代码.它展示了如何在两个 RecyclerView
之间Drag and Drop
.
If you are still interested in a simple solution see my code on GitHub. It's shows how to Drag and Drop
between two RecyclerView
s.
这篇关于在两个回收视图之间拖放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!