Android WebView-手势-拖动项目?
我正在使用WebView显示网站。这部分基本正常 在普通浏览器(Chrome等)中查看网站时,您可以“左键单击”项目,然后在页面上拖动它们以重新排列它们。在Android设备上使用WebView查看页面时,此功能不起作用 当您“单击”(并按住)WebView中的项目时,屏幕顶部会弹出“复制/剪切”弹出窗口,当您尝试移动/滑动时,它只会垂直或水平滚动页面 我不确定我需要添加什么才能使网站上发生的相同类型的“点击-拖动”手势动作在WebView中发生 同样在网站版本上,如果你右键点击一个项目,它会弹出一个上下文菜单。这一部分在安卓设备上工作。如果您单击某个项目,然后再次单击,它将根据网站版本显示上下文菜单。只是“点击拖动”功能,我不知道如何实现 任何建议都很好 下面是代码 ManiActivity.javaAndroid WebView-手势-拖动项目?,android,webview,android-webview,gesture,netbeans-8,Android,Webview,Android Webview,Gesture,Netbeans 8,我正在使用WebView显示网站。这部分基本正常 在普通浏览器(Chrome等)中查看网站时,您可以“左键单击”项目,然后在页面上拖动它们以重新排列它们。在Android设备上使用WebView查看页面时,此功能不起作用 当您“单击”(并按住)WebView中的项目时,屏幕顶部会弹出“复制/剪切”弹出窗口,当您尝试移动/滑动时,它只会垂直或水平滚动页面 我不确定我需要添加什么才能使网站上发生的相同类型的“点击-拖动”手势动作在WebView中发生 同样在网站版本上,如果你右键点击一个项目,它会弹
package org.webview.test;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Initialize the myWebView object
WebView myWebView = (WebView) findViewById(R.id.webview);
// Zoom control - sets onsreen controls
myWebView.getSettings().setSupportZoom(true);
myWebView.getSettings().setBuiltInZoomControls(true);
// Make webpage fit to screen size
myWebView.getSettings().setLoadWithOverviewMode(true);
myWebView.getSettings().setUseWideViewPort(true);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
// Force links and redirects to open in the WebView instead of in a browser
myWebView.setWebViewClient(new CustomWebViewClient());
// Make scroll bars visible
myWebView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
myWebView.setScrollbarFadingEnabled(false);
// Web page to load in WebView
myWebView.loadUrl(getString(R.string.url));
}
// Force links and redirects to open in the WebView instead of in a browser
private class CustomWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url);
return true; }
}
}
Main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.webview.test"
android:versionCode="1"
android:versionName="1.0">
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
<activity android:name="MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<!-- Gives device access to internet-->
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
我想我已经取得了一些进展,但仍然不知道如何正确地/正确地实现这一点,如果它可以完全停止的话?我认为在WebView链接到的实际网页中,我需要添加相关的元标记,这样它就可以被认为是移动的,但仍然不确定在Android端该做什么。非常感谢任何信息!