本文整理汇总了Java中android.webkit.WebView.setFocusableInTouchMode方法的典型用法代码示例。如果您正苦于以下问题:Java WebView.setFocusableInTouchMode方法的具体用法?Java WebView.setFocusableInTouchMode怎么用?Java WebView.setFocusableInTouchMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.webkit.WebView
的用法示例。
在下文中一共展示了WebView.setFocusableInTouchMode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.webkit.WebView; //导入方法依赖的package包/类
/**
* Called when the activity is first created. Set the web view layout and
* get the title and file to be displayed.
*
* @param savedInstanceState
* Is used to save the state of the created Activity.
*
* @author Yuriy Stanchev
*
* @email [email protected]
*
* @date 11 Mar 2012
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
Bundle extras = intent.getExtras();
String title = (String) extras.get("title");
String file = (String) extras.get("file");
setContentView(R.layout.about);
setTitle(title);
WebView view = (WebView) findViewById(R.id.web);
view.setFocusable(true);
view.setFocusableInTouchMode(true);
view.requestFocus();
view.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
view.loadUrl(file);
}
示例2: onCreate
import android.webkit.WebView; //导入方法依赖的package包/类
/**
* Called when the activity is first created. Set the web view layout and
* get the title and file to be displayed.
*
* @param savedInstanceState
* Is used to save the state of the created Activity.
*
* @author Yuriy Stanchev
*
* @email [email protected]
*
* @date 11 Mar 2012
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
Bundle extras = intent.getExtras();
String title = (String) extras.get("title");
String file = (String) extras.get("file");
setContentView(R.layout.about);
setTitle(title);
WebView view = (WebView) findViewById(R.id.web);
view.setFocusable(true);
view.setFocusableInTouchMode(true);
view.requestFocus();
view.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
view.loadUrl(file);
// Initialize the databases for the AIs.
// Intent AIDBInitialization = new Intent(getApplicationContext(),
// AIDBInitialization.class);
// startActivity(AIDBInitialization);
}
示例3: initializeAUTWebView
import android.webkit.WebView; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@SuppressLint("SetJavaScriptEnabled")
private WebView initializeAUTWebView()
{
// Intialize AUT WebView and set properties
final WebView webView = getAUTWebView();
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
// Clear all cookies on TTW launch
CookieSyncManager.createInstance(this);
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookie();
webView.getSettings().setSaveFormData(false);
webView.setFocusable(true);
webView.setFocusableInTouchMode(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setBuiltInZoomControls(true);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2)
{
webView.getSettings().setRenderPriority(RenderPriority.HIGH);
webView.getSettings().setSavePassword(false);
}
// Setup WebViewClient and Progress Bar
webView.setWebViewClient(new SimpleWebViewClient(this));
webView.setWebChromeClient(new SimpleWebChromeClient(this, webView));
// Retrieved the TTW user-agent from the shared preference file
SharedPreferences pref = getSharedPreferences(MainSettingsActivity.BASE_CLASS_NAME, Context.MODE_PRIVATE);
String userAgent = pref.getString(MainSettingsActivity.USER_AGENT_KEY, "");
if (!userAgent.isEmpty())
{
// The user has defined the user-agent
webView.getSettings().setUserAgentString(userAgent);
}
else
{
// Use the default user agent
webView.getSettings().setUserAgentString(s_userAgentDefault);
}
return webView;
}
示例4: 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);
}
示例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();
}
}