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

下面列出了android.webkit.WebView#setFocusableInTouchMode ( ) 实例代码,或者点击链接到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 项目: 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();
    }
}
 
源代码8 项目: 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();
    }
}