當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。