当前位置: 首页>>代码示例>>Java>>正文


Java WebView.setOnTouchListener方法代码示例

本文整理汇总了Java中android.webkit.WebView.setOnTouchListener方法的典型用法代码示例。如果您正苦于以下问题:Java WebView.setOnTouchListener方法的具体用法?Java WebView.setOnTouchListener怎么用?Java WebView.setOnTouchListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.webkit.WebView的用法示例。


在下文中一共展示了WebView.setOnTouchListener方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import android.webkit.WebView; //导入方法依赖的package包/类
private void init(){
    LinearLayout layout = (LinearLayout) findViewById(R.id.Download_layout);
    layout.setVisibility(View.GONE);

    Intent intent = getIntent();
    body = intent.getStringExtra("body");
    title = intent.getStringExtra("title");
    contentView = (WebView) findViewById(R.id.content_webview);
    contentView.setHorizontalScrollBarEnabled(false);//水平不显示
    contentView.setVerticalScrollBarEnabled(false); //垂直不显示

    contentView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return (event.getAction() == MotionEvent.ACTION_MOVE);
        }
    });
    contentView.setWebViewClient(new WebViewClient());

    topImage = (ImageView) findViewById(R.id.top_image);
    topTitle = (TextView) findViewById(R.id.top_titlt);
    topSource = (TextView) findViewById(R.id.top_source);
}
 
开发者ID:ChenTianSaber,项目名称:DailyZhiHu,代码行数:24,代码来源:DownloadDetaiContentActivity.java

示例2: init

import android.webkit.WebView; //导入方法依赖的package包/类
private void init(){

        Intent intent = getIntent();
        contentId = intent.getStringExtra("contentId");
        contentView = (WebView) findViewById(R.id.content_webview);
        contentView.setHorizontalScrollBarEnabled(false);//水平不显示
        contentView.setVerticalScrollBarEnabled(false); //垂直不显示

        contentView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                return (event.getAction() == MotionEvent.ACTION_MOVE);
            }
        });
        contentView.setWebViewClient(new WebViewClient());

        topImage = (ImageView) findViewById(R.id.top_image);
        topTitle = (TextView) findViewById(R.id.top_titlt);
        topSource = (TextView) findViewById(R.id.top_source);
    }
 
开发者ID:ChenTianSaber,项目名称:DailyZhiHu,代码行数:21,代码来源:DetaiContentActivity.java

示例3: setUpWebView

import android.webkit.WebView; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private void setUpWebView(int margin) {
    LinearLayout webViewContainer = new LinearLayout(getContext());
    webView = new WebView(getContext().getApplicationContext()) {
        /* Prevent NPE on Motorola 2.2 devices
         * See https://groups.google.com/forum/?fromgroups=#!topic/android-developers/ktbwY2gtLKQ
         */
        @Override
        public void onWindowFocusChanged(boolean hasWindowFocus) {
            try {
                super.onWindowFocusChanged(hasWindowFocus);
            } catch (NullPointerException e) {
            }
        }
    };
    webView.setVerticalScrollBarEnabled(false);
    webView.setHorizontalScrollBarEnabled(false);
    webView.setWebViewClient(new DialogWebViewClient());
    webView.getSettings().setJavaScriptEnabled(true);
    webView.loadUrl(url);
    webView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    webView.setVisibility(View.INVISIBLE);
    webView.getSettings().setSavePassword(false);
    webView.getSettings().setSaveFormData(false);
    webView.setFocusable(true);
    webView.setFocusableInTouchMode(true);
    webView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (!v.hasFocus())
            {
                v.requestFocus();
            }
            return false;
        }
    });

    webViewContainer.setPadding(margin, margin, margin, margin);
    webViewContainer.addView(webView);
    webViewContainer.setBackgroundColor(BACKGROUND_GRAY);
    contentFrameLayout.addView(webViewContainer);
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:44,代码来源:WebDialog.java

示例4: WebViewer

import android.webkit.WebView; //导入方法依赖的package包/类
/**
 * Creates a new WebViewer component.
 *
 * @param container  container the component will be placed in
 */
public WebViewer(ComponentContainer container) {
  super(container);

  webview = new WebView(container.$context());
  resetWebViewClient();       // Set up the web view client
  webview.getSettings().setJavaScriptEnabled(true);
  webview.setFocusable(true);
  // adds a way to send strings to the javascript
  wvInterface = new WebViewInterface(webview.getContext());
  webview.addJavascriptInterface(wvInterface, "AppInventor");
  // enable pinch zooming and zoom controls
  webview.getSettings().setBuiltInZoomControls(true);

  if (SdkLevel.getLevel() >= SdkLevel.LEVEL_ECLAIR)
    EclairUtil.setupWebViewGeoLoc(this, webview, container.$context());

  container.$add(this);

  webview.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
      switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
        case MotionEvent.ACTION_UP:
          if (!v.hasFocus()) {
            v.requestFocus();
          }
          break;
      }
      return false;
    }
  });

  // set the initial default properties.  Height and Width
  // will be fill-parent, which will be the default for the web viewer.

  HomeUrl("");
  Width(LENGTH_FILL_PARENT);
  Height(LENGTH_FILL_PARENT);
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:46,代码来源:WebViewer.java

示例5: LightningView

import android.webkit.WebView; //导入方法依赖的package包/类
public LightningView(@NonNull Activity activity, @Nullable String url, boolean isIncognito) {
    BrowserApp.getAppComponent().inject(this);
    mActivity = activity;
    mUIController = (UIController) activity;
    mWebView = new WebView(activity);
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
        mWebView.setId(View.generateViewId());
    }
    mIsIncognitoTab = isIncognito;
    mTitle = new LightningViewTitle(activity);

    sMaxFling = ViewConfiguration.get(activity).getScaledMaximumFlingVelocity();

    mWebView.setDrawingCacheBackgroundColor(Color.WHITE);
    mWebView.setFocusableInTouchMode(true);
    mWebView.setFocusable(true);
    mWebView.setDrawingCacheEnabled(false);
    mWebView.setWillNotCacheDrawing(true);
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
        //noinspection deprecation
        mWebView.setAnimationCacheEnabled(false);
        //noinspection deprecation
        mWebView.setAlwaysDrawnWithCacheEnabled(false);
    }
    mWebView.setBackgroundColor(Color.WHITE);

    mWebView.setScrollbarFadingEnabled(true);
    mWebView.setSaveEnabled(true);
    mWebView.setNetworkAvailable(true);
    mWebView.setWebChromeClient(new LightningChromeClient(activity, this));
    mWebView.setWebViewClient(new LightningWebClient(activity, this));
    mWebView.setDownloadListener(new LightningDownloadListener(activity));
    mGestureDetector = new GestureDetector(activity, new CustomGestureListener());
    mWebView.setOnTouchListener(new TouchListener());
    sDefaultUserAgent = mWebView.getSettings().getUserAgentString();
    initializeSettings();
    initializePreferences(activity);

    if (url != null) {
        if (!url.trim().isEmpty()) {
            mWebView.loadUrl(url, mRequestHeaders);
        } else {
            // don't load anything, the user is looking for a blank tab
        }
    } else {
        loadHomepage();
    }
}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:49,代码来源:LightningView.java


注:本文中的android.webkit.WebView.setOnTouchListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。