And*_*ndy 4 android image webview
我倾注了类似的问题,但找不到答案.我希望能够长时间在我的webview中按下用户上传的图像来保存它们(就像你可以在浏览器中一样).有帮助吗?
更新:
现在使用我自己的自定义项目"保存图像"弹出上下文菜单.我甚至可以成功干杯msgs.我如何保存图像呢?长时间点击的图像是否会传递到我的菜单项?
public boolean onLongClick(View v) {
openContextMenu(v);
return true;
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.context, menu);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
switch (item.getItemId()) {
case R.id.save_image:
Toast.makeText(this, "save failed",
Toast.LENGTH_LONG).show();
return true;
default:
return super.onContextItemSelected(item);
}
}
Run Code Online (Sandbox Code Playgroud)
首先注册WebView以获取上下文菜单,如下所示: activity.registerForContextMenu(webView)
@Override
protected void onCreateContextMenu(ContextMenu menu) {
super.onCreateContextMenu(menu);
HitTestResult result = getHitTestResult();
MenuItem.OnMenuItemClickListener handler = new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
// do the menu action
return true;
}
};
if (result.getType() == HitTestResult.IMAGE_TYPE ||
result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
menu.setHeaderTitle(result.getExtra());
menu.add(0, ID_SAVEIMAGE, 0, "Save Image").setOnMenuItemClickListener(handler);
}
Run Code Online (Sandbox Code Playgroud)
要保存图像,只需使用它
| 归档时间: |
|
| 查看次数: |
8497 次 |
| 最近记录: |