在Android的WebView上下文菜单 [英] Context Menu on Android WebView

查看:545
本文介绍了在Android的WebView上下文菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想添加上下文菜单上的整个机器人的WebView。我有以下的code:

I'd like to add a context menu on an entire Android WebView. I have the following code:

registerForContextMenu(findViewById(R.id.webview));
...
public void onCreateContextMenu (ContextMenu menu, View v, ContextMenuInfo menuInfo) {
   super.onCreateContextMenu(menu, v, menuInfo);
   if (v.getId() == R.id.webview) {       
       //display context menu
   }
}

我注意到,上下文菜单,当一个preSS是在由web视图渲染网页的链接做才会显示。当长preSS是Web视图中的空白区域做(空或纯文本区域的网页)不显示上下文菜单。

I noticed that the context menu is only displayed when a long press is done on a link in the webpage rendered by the WebView. When a long press is done in an empty area of the web view (an empty or text only area of the web page) the context menu is not displayed.

有关如何显示上下文菜单整个网页,不仅为链接任何想法?

Any idea about how to display a context menu for the entire webpage and not only for links?

推荐答案

http://developer.android.com/reference/android/view/View.OnLongClickListener.html

看看onLongClick(),然后实现与列表的对话框。

Take a look at onLongClick() and then implement on your dialog with a list.

这篇关于在Android的WebView上下文菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆