1

我正在尝试寻找一种方法来使用javascriptcss(不是 Java)来防止 Android 设备在长按网页中的图像或锚点等 html 元素时显示弹出对话框。

我正在尝试制作旋转木马,如果我在旋转木马上按住左箭头或右箭头,会弹出一个窗口,要求我在新标签中打开,保存图像等。我可以在 iOS/ 上轻松完成此操作带有 CSS 规则的 Safari。

我试图抑制的对话框的屏幕截图

提前致谢。

4

1 回答 1

0

how are you setting your setOnLongClickListener and onTouch?

make sure it's similar to this

setOnLongClickListener(new View.OnLongClickListener() {

    public boolean onLongClick(View view) {

      activity.openContextMenu(view);  

     return true;  // avoid extra click events

    }

});

setOnTouch(new View.OnTouchListener(){

  public boolean onTouch(View v, MotionEvent e){

    switch(e.getAction & MotionEvent.ACTION_MASK){

      // do drag/gesture processing. 

    }

// you MUST return false for ACTION_DOWN and ACTION_UP, for long click to work
// you can return true for ACTION_MOVEs that you consume. 
// DOWN/UP are needed by the long click timer.
// if you want, you can consume the UP if you have made a drag - so that after 
// a long drag, no long-click is generated.

    return false;

  }

});

setLongClickable(true);

code curtosy of Sanjay Manohar Detect touch press vs long press vs movement?

于 2012-08-15T15:33:15.157 回答