android.webkit.WebView#setFocusable ( )源码实例Demo

下面列出了android.webkit.WebView#setFocusable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@SuppressWarnings("static-access")
public static void handleContentTV(final WebView contentTV, final MessageArticlePageInfo row, int bgColor, int fgColor, Context context) {
    final WebViewClient client = new WebViewClientEx((FragmentActivity) context);
    contentTV.setBackgroundColor(0);
    contentTV.setFocusableInTouchMode(false);
    contentTV.setFocusable(false);
    contentTV.setLongClickable(false);


    WebSettings setting = contentTV.getSettings();
    setting.setUserAgentString(context.getString(R.string.clientua) + BuildConfig.VERSION_CODE);
    setting.setDefaultFontSize(PhoneConfiguration.getInstance()
            .getWebSize());
    setting.setJavaScriptEnabled(false);
    contentTV.setWebViewClient(client);

    contentTV.setTag(row.getLou());
    contentTV.loadDataWithBaseURL(null, row.getFormated_html_data(),
            "text/html", "utf-8", null);
}
 
源代码2 项目: commcare-android   文件: GraphView.java
@TargetApi(Build.VERSION_CODES.KITKAT)
public WebView getView(String html) {
    if (BuildConfig.DEBUG) {
        WebView.setWebContentsDebuggingEnabled(true);
    }

    WebView webView = new GraphWebView(mContext);

    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);

    webView.setClickable(true);
    webView.setFocusable(false);
    webView.setFocusableInTouchMode(false);

    settings.setBuiltInZoomControls(mIsFullScreen);
    settings.setSupportZoom(mIsFullScreen);
    settings.setDisplayZoomControls(mIsFullScreen);

    // Improve performance
    settings.setCacheMode(WebSettings.LOAD_NO_CACHE);

    this.myHTML = html;
    webView.loadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null);
    return webView;
}
 
源代码3 项目: PowerFileExplorer   文件: AboutActivity.java
@Override
protected void onCreate(Bundle savedInstanceState)
{
	super.onCreate(savedInstanceState);
	setContentView(R.layout.about);

	String url = DEFAULT_PAGE;

	Intent it = getIntent();
	if ( it != null ){
		Bundle extras = it.getExtras();
		if ( extras !=null ){
			String iturl = extras.getString(EXTRA_URL);
			if ( iturl !=null ){
				url = iturl;
			}
			String ittitle = extras.getString(EXTRA_TITLE);
			if ( ittitle !=null ){
				setTitle( ittitle );
			}
		}else{
		    url = getString(R.string.about_url);
               setTitle( R.string.about_title );
		}
	}

	WebView webview = (WebView)findViewById(R.id.WebView01);
	webview.loadUrl( url );

	mjsobj = new JsCallbackObj();
	webview.addJavascriptInterface(mjsobj, "jscallback");

	webview.getSettings().setJavaScriptEnabled(true);
	webview.setFocusable(true);
	webview.setFocusableInTouchMode(true);
}
 
源代码4 项目: JotaTextEditor   文件: AboutActivity.java
@Override
protected void onCreate(Bundle savedInstanceState)
{
	super.onCreate(savedInstanceState);
	setContentView(R.layout.about);

	String url = DEFAULT_PAGE;

	Intent it = getIntent();
	if ( it != null ){
		Bundle extras = it.getExtras();
		if ( extras !=null ){
			String iturl = extras.getString(EXTRA_URL);
			if ( iturl !=null ){
				url = iturl;
			}
			String ittitle = extras.getString(EXTRA_TITLE);
			if ( ittitle !=null ){
				setTitle( ittitle );
			}
		}else{
		    url = getString(R.string.about_url);
               setTitle( R.string.about_title );
		}
	}

	WebView webview = (WebView)findViewById(R.id.WebView01);
	webview.loadUrl( url );

	mjsobj = new JsCallbackObj();
	webview.addJavascriptInterface(mjsobj, "jscallback");

	webview.getSettings().setJavaScriptEnabled(true);
	webview.setFocusable(true);
	webview.setFocusableInTouchMode(true);
}
 
源代码5 项目: Android_Skin_2.0   文件: WebInitCompat.java
@Override
public void setDefaultAttr(WebView view) {
	// 去除滚动条白色背景,必须在代码里面添加才有效
	view.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
	view.setScrollbarFadingEnabled(true);
	view.setDrawingCacheEnabled(true);
	view.setLongClickable(true);
	view.setBackgroundResource(android.R.color.transparent);
	view.setBackgroundColor(Color.TRANSPARENT);
	view.getBackground().setAlpha(0);
	view.setFocusable(true);
	view.setFocusableInTouchMode(true);
}
 
源代码6 项目: kognitivo   文件: WebDialog.java
@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);
}
 
源代码7 项目: appinventor-extensions   文件: WebViewer.java
/**
 * 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.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);
}
 
源代码8 项目: Xndroid   文件: LightningView.java
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();
    }
}
 
源代码9 项目: chat-window-android   文件: ChatWindowView.java
private void initView(Context context) {
    setFitsSystemWindows(true);
    setVisibility(GONE);
    LayoutInflater.from(context).inflate(R.layout.view_chat_window_internal, this, true);
    webView = (WebView) findViewById(R.id.chat_window_web_view);
    statusText = (TextView) findViewById(R.id.chat_window_status_text);
    progressBar = (ProgressBar) findViewById(R.id.chat_window_progress);
    reloadButton = (Button) findViewById(R.id.chat_window_button);
    reloadButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            reload();
        }
    });

    if (Build.VERSION.RELEASE.matches("4\\.4(\\.[12])?")) {
        String userAgentString = webView.getSettings().getUserAgentString();
        webView.getSettings().setUserAgentString(userAgentString + " AndroidNoFilesharing");
    }

    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.setAcceptCookie(true);

    webView.setFocusable(true);
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setAppCacheEnabled(true);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    webSettings.setSupportMultipleWindows(true);
    webSettings.setDomStorageEnabled(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        cookieManager.getInstance().setAcceptThirdPartyCookies(webView, true);
    }

    webView.setWebViewClient(new LCWebViewClient());
    webView.setWebChromeClient(new LCWebChromeClient());

    webView.requestFocus(View.FOCUS_DOWN);
    webView.setVisibility(GONE);

    webView.setOnTouchListener(new View.OnTouchListener() {
        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;
        }
    });
    webView.addJavascriptInterface(new ChatWindowJsInterface(this), ChatWindowJsInterface.BRIDGE_OBJECT_NAME);
}
 
源代码10 项目: JumpGo   文件: LightningView.java
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));
    mLightningWebClient = new LightningWebClient(activity, this);
    mWebView.setWebViewClient(mLightningWebClient);
    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();
    }
}