What you are trying to do is synchronize the listviews. There is a library that already implements this for two listviews here. I will try to explain the part of the source code relevant to you which is located in the activity here.
Suppose if you have access to all your listviews through variables:
listViewOne = (ListView) findViewById(R.id.list_view_one);
listViewTwo = (ListView) findViewById(R.id.list_view_two);
listViewThree = (ListView) findViewById(R.id.list_view_three);
listViewFour = (ListView) findViewById(R.id.list_view_four);
Set the same touch listeners on them:
listViewOne.setOnTouchListener(touchListener);
listViewTwo.setOnTouchListener(touchListener);
// similarly for listViewThree & listViewFour
The basic idea of the touch listener is to dispatch events to the other views so that they also scroll synchronously with the listview being touched.
// Passing the touch event to the opposite list
OnTouchListener touchListener = new OnTouchListener() {
boolean dispatched = false;
@Override
public boolean onTouch(View v, MotionEvent event) {
if (v.equals(listViewOne) && !dispatched) {
dispatched = true;
listViewTwo.dispatchTouchEvent(event);
listViewThree.dispatchTouchEvent(event);
listViewFour.dispatchTouchEvent(event);
} else if (v.equals(listViewTwo) && !dispatched) {
dispatched = true;
listViewOne.dispatchTouchEvent(event);
listViewThree.dispatchTouchEvent(event);
listViewFour.dispatchTouchEvent(event);
} // similarly for listViewThree & listViewFour
dispatched = false;
return false;
}
};
The library also has set a scroll listener, which I believe is used because the views may be of differing heights, which you don't have. Try and let me know if this works.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…