以下是我的代码: 但我的pos值为0。 请帮忙
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view);
pos = listView.pointToPosition((int) motionEvent.getX(), (int) motionEvent.getY());
view.startDrag(null, shadowBuilder, view, 0);
return true;
}
}
答案 0 :(得分:0)
按以下应用
中所示进行更改DragShadowBuilder shadowBuilder;
public boolean onTouch(View view, MotionEvent motion)
if (motionEvent.getAction() == Motion.ACTION_DOWN) {
shadowBuilder = new View.DragShadowBuilder(view);
pos = listView.pointToPosition((int) motion.getX(), (int) motion.getY());
Toast.makeText(getApplicationContext(),"Pos is:"+pos,Toast.LENGTH_SHORT).show();
view.startDrag(null, shadowBuilder, view, 0);
return false;
}
}