Example usage for android.webkit WebView setClickable

List of usage examples for android.webkit WebView setClickable

Introduction

In this page you can find the example usage for android.webkit WebView setClickable.

Prototype

public void setClickable(boolean clickable) 

Source Link

Document

Enables or disables click events for this view.

Usage

From source file:com.owncloud.android.ui.activity.ExternalSiteWebView.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log_OC.v(TAG, "onCreate() start");

    Bundle extras = getIntent().getExtras();
    String title = extras.getString(EXTRA_TITLE);
    String url = extras.getString(EXTRA_URL);
    menuItemId = extras.getInt(EXTRA_MENU_ITEM_ID);
    showSidebar = extras.getBoolean(EXTRA_SHOW_SIDEBAR);

    // show progress
    getWindow().requestFeature(Window.FEATURE_PROGRESS);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.externalsite_webview);

    WebView webview = (WebView) findViewById(R.id.webView);
    WebSettings webSettings = webview.getSettings();

    webview.setFocusable(true);//from  w  ww  . j  av  a  2s  . c  o  m
    webview.setFocusableInTouchMode(true);
    webview.setClickable(true);

    // setup toolbar
    setupToolbar();

    // setup drawer
    setupDrawer(menuItemId);

    if (!showSidebar) {
        setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
    }

    getSupportActionBar().setTitle(title);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // enable zoom
    webSettings.setSupportZoom(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setDisplayZoomControls(false);

    // Non-responsive webs are zoomed out when loaded
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);

    // user agent
    webSettings.setUserAgentString(MainApp.getUserAgent());

    // no private data storing
    webSettings.setSavePassword(false);
    webSettings.setSaveFormData(false);

    // disable local file access
    webSettings.setAllowFileAccess(false);

    // enable javascript
    webview.getSettings().setJavaScriptEnabled(true);

    final Activity activity = this;
    final ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar);

    webview.setWebChromeClient(new WebChromeClient() {
        public void onProgressChanged(WebView view, int progress) {
            progressBar.setProgress(progress * 1000);
        }
    });

    webview.setWebViewClient(new WebViewClient() {
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            Toast.makeText(activity, getString(R.string.webview_error) + ": " + description, Toast.LENGTH_SHORT)
                    .show();
        }
    });

    webview.loadUrl(url);
}