我正在创建一个可拖动的 editText,我使用 editText 来允许用户更改文本。但我现在的问题是我无法再编辑文本,因为它检测到文本的触摸/拖动。
有什么解决办法吗?
private final class MyTouchListener implements OnTouchListener {
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction() & MotionEvent.ACTION_MASK)
{
case MotionEvent.ACTION_DOWN:
ClipData data = ClipData.newPlainText("", "");
DragShadowBuilder shadowBuilder = new DragShadowBuilder(view);
view.startDrag(data, shadowBuilder, view, 0);
view.setVisibility(View.VISIBLE);
break;
case MotionEvent.ACTION_MOVE:
break;
case MotionEvent.ACTION_UP:
break;
case MotionEvent.ACTION_HOVER_EXIT:
break;
}
return true;
}
}
我有拖动监听器
class MyDragListener implements OnDragListener {
@Override
public boolean onDrag(View v, DragEvent event) {
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
break;
case DragEvent.ACTION_DRAG_ENTERED:
break;
case DragEvent.ACTION_DRAG_EXITED:
break;
case DragEvent.ACTION_DROP:
View view = (View) event.getLocalState();
paramsBlock = new RelativeLayout.LayoutParams(view.getWidth(), view.getWidth());
paramsBlock.leftMargin = (int) event.getX() - (view.getWidth()/2);//- ((imageView.getWidth()/9)/2);
paramsBlock.topMargin = (int) event.getY() -(view.getHeight()/2);//-((imageView.getWidth()/9)/2);
view.setLayoutParams(paramsBlock);
break;
case DragEvent.ACTION_DRAG_ENDED:
default:
break;
}
return true;
}
}
可以使用onLongClick
监听器吗?