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;
}
Customised this library and got the things that I want. Link - https://github.com/woxblom/DragListView
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…