android.webkit.WebView.setOnTouchListener()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(250)

本文整理了Java中android.webkit.WebView.setOnTouchListener()方法的一些代码示例,展示了WebView.setOnTouchListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebView.setOnTouchListener()方法的具体详情如下:
包路径:android.webkit.WebView
类名称:WebView
方法名:setOnTouchListener

WebView.setOnTouchListener介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

webView.setOnTouchListener(this);

代码示例来源:origin: novoda/android-demos

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.webview_main);
  webView = (WebView) findViewById(R.id.webview_main);
  webView.loadUrl("file:///android_asset/two_columns.html");
  fontSize = webView.getSettings().getDefaultFontSize();
  
  if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH)) {
    webView.setOnTouchListener(touchListener);
    zoomDetector = new PinchZoomDetector();
  }
}

代码示例来源:origin: facebook/facebook-android-sdk

webView.setFocusable(true);
webView.setFocusableInTouchMode(true);
webView.setOnTouchListener(new View.OnTouchListener() {
  @Override
  public boolean onTouch(View v, MotionEvent event) {

代码示例来源:origin: stackoverflow.com

myWebView.setOnTouchListener(gestureListener);

代码示例来源:origin: JasonQS/Anti-recall

webView.setOnTouchListener((v, event) -> {
  webView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
  return false;

代码示例来源:origin: stackoverflow.com

WebView webView = (WebView) findViewById(R.id.noticetit);
private void setWebView() {
      String htmlcss = "<html lang=\"he\"><head><meta charset=\"utf-8\" />"
          + "<style type=\"text/css\">.rtl {direction: rtl;color:black;font:20px arial;}</style></head>"
          + "<body class=\"rtl\"><div class=\"rtl\">" + webView
          + "</div></body></html>";

      webView.loadDataWithBaseURL(null, htmlcss, "text/html", "utf-8", null);
      webView.setOnTouchListener(new OnTouchListener() {
        // Removed @Override
        public boolean onTouch(View v, MotionEvent event) {
          if (v.getId() == R.id.maintitle
              && event.getAction() == MotionEvent.ACTION_DOWN) {
            //Put your code here
          }
          return false;
        }
      });
    }

代码示例来源:origin: stackoverflow.com

WebView webView = (WebView) findViewById(R.id.noticetit);
private void setWebView() {
      String htmlcss = "<html lang=\"he\"><head><meta charset=\"utf-8\" />"
          + "<style type=\"text/css\">.rtl {direction: rtl;color:black;font:20px arial;}</style></head>"
          + "<body class=\"rtl\"><div class=\"rtl\">" + webView
          + "</div></body></html>";

      webView.loadDataWithBaseURL(null, htmlcss, "text/html", "utf-8", null);
      webView.setOnTouchListener(new OnTouchListener() {
        // Removed @Override
        public boolean onTouch(View v, MotionEvent event) {
          if (v.getId() == R.id.maintitle
              && event.getAction() == MotionEvent.ACTION_DOWN) {
            //Put your code here
          }
          return false;
        }
      });
    }

代码示例来源:origin: stackoverflow.com

private void init(){
  WebView web = new WebView(this);
  final Context context = this;
  web.setOnTouchListener(new OnTouchListener() {

    public boolean onTouch(View arg0, MotionEvent event) {
      // TODO Auto-generated method stub
      switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        // show action bar
        ((Activity) context).getActionBar().show();
        break;

      case MotionEvent.ACTION_UP:
        // hide action bar
        ((Activity) context).getActionBar().hide();
        break;

      default:
        break;
      }
      return false;
    }
  });
}

代码示例来源:origin: stackoverflow.com

public class MyWebView extends Activity {
   /** Called when the activity is first created. */
   String TAG = this.getClass().getSimpleName();
   WebView wv;
   @Override
   public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.main);
     wv = (WebView) findViewById(R.id.MyWebView);
     wv.getSettings().setJavaScriptEnabled(true);
     wv.setWebViewClient(new VideoWebViewClient());
     wv.getSettings().setUserAgentString("Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
     wv.loadUrl("http://www.w3schools.com/html/tryit.asp?filename=tryhtml_form_radio");
     wv.setOnTouchListener(new View.OnTouchListener() {
       public boolean onTouch(View v, MotionEvent event) {
         WebView.HitTestResult hr = ((WebView)v).getHitTestResult();
         Log.i(TAG, "getExtra = "+ hr.getExtra() + "\t\t Type=" + hr.getType());
         return false;
       }
     });
   }
   private class VideoWebViewClient extends WebViewClient {
     @Override
     public boolean shouldOverrideUrlLoading(WebView view, String url) {
       view.loadUrl(url);
       return false;
     }
   }
 }

代码示例来源:origin: stackoverflow.com

webView.setPictureListener(this);
webView.setOnTouchListener(new View.OnTouchListener() {

代码示例来源:origin: stackoverflow.com

public class MainActivity extends AppCompatActivity {
  @Override
  protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final WebView webView = new WebView(this);
    setContentView(webView);

    webView.setWebViewClient(new HelloWebViewClient());

    webView.loadUrl("http://www.google.com");

    webView.setOnTouchListener(new View.OnTouchListener() {
      @Override
      public boolean onTouch(View v, MotionEvent event) {
        return true;
      }
    });
  }

  public class HelloWebViewClient extends WebViewClient {
    // Catch additional url loading
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
      return true;
    }
  }
}

代码示例来源:origin: ymback/NGA-CLIENT-VER-OPEN-SOURCE

@Override
public void onProgressChanged(WebView view, int newProgress) {
  super.onProgressChanged(view, newProgress);
  view.requestFocus(View.FOCUS_DOWN);
  view.setOnTouchListener(new View.OnTouchListener() {
    @SuppressLint("ClickableViewAccessibility")
    @Override
    public boolean onTouch(View v, MotionEvent event) {
      switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
        case MotionEvent.ACTION_UP:
          if (!v.hasFocus()) {
            v.requestFocus(View.FOCUS_DOWN);
          }
          break;
      }
      return false;
    }
  });
}

代码示例来源:origin: stackoverflow.com

myBrowser.setOnTouchListener(new View.OnTouchListener() {

代码示例来源:origin: stackoverflow.com

myBrowser.setOnTouchListener(new View.OnTouchListener() {

代码示例来源:origin: SunAlwaysOnline/Sukeda

private void initWebView() {
  WebSettings settings = webView.getSettings();
  settings.setJavaScriptEnabled(true);
  settings.setJavaScriptCanOpenWindowsAutomatically(true);
  //settings.setDefaultTextEncodingName("utf-8");
  settings.setAppCacheEnabled(true);
  settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
  //settings.setUseWideViewPort(true);
  //settings.setLoadWithOverviewMode(true);
  settings.setTextSize(WebSettings.TextSize.NORMAL);
  //禁止webview点击
  webView.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View view, MotionEvent motionEvent) {
      return true;
    }
  });
}

代码示例来源:origin: stackoverflow.com

webView.setOnTouchListener(this);

代码示例来源:origin: apps4av/avare

mWebView.setOnTouchListener(new View.OnTouchListener() {  
  @Override
  public boolean onTouch(View arg0, MotionEvent arg1) {

代码示例来源:origin: XieShengda/News

webSettings.setJavaScriptEnabled(true);
webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
webView.setOnTouchListener(this);
webView.setWebChromeClient(new WebChromeClient(){
  @Override

代码示例来源:origin: andforce/iBeebo

large.setOnTouchListener(new LargeOnTouchListener(large));

代码示例来源:origin: kebernet/shortyz

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  utils.holographic(this);
  utils.finishOnHomeButton(this);
  this.setContentView(R.layout.html_view);
  ActionBar actionBar = getSupportActionBar();
  actionBar.hide();
  WebView webview = (WebView) this.findViewById(R.id.webkit);
  Uri u = this.getIntent()
        .getData();
  webview.loadUrl(u.toString());
  FloatingActionButton download = (FloatingActionButton) this.findViewById(R.id.button_floating_action);
  if(download != null) {
    download.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        finish();
      }
    });
    download.setImageBitmap(createBitmap("icons1.ttf", "k"));
    webview.setOnTouchListener(new ShowHideOnScroll(download));
  }
}

相关文章

WebView类方法