当前位置: 首页>>代码示例>>Java>>正文


Java WebView.setFocusable方法代码示例

本文整理汇总了Java中android.webkit.WebView.setFocusable方法的典型用法代码示例。如果您正苦于以下问题:Java WebView.setFocusable方法的具体用法?Java WebView.setFocusable怎么用?Java WebView.setFocusable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.webkit.WebView的用法示例。


在下文中一共展示了WebView.setFocusable方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);

}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:37,代码来源:AboutActivity.java

示例2: initWebView

import android.webkit.WebView; //导入方法依赖的package包/类
private static void initWebView(WebView webview) {
    webview.setFocusable(true);
    webview.setInitialScale(0); // imdb does not look good in fullscreen with anything but this
    webview.getSettings().setJavaScriptEnabled(true);
    webview.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (DBG) Log.d(TAG, "shouldOverrideUrlLoading " + url);
            return false;
        }
    });
    // Remove 'Mobile' from the user agent to avoid phone-version of IMDB on TV screen...
    String userAgent = webview.getSettings().getUserAgentString();
    userAgent = userAgent.replace("Mobile", " ");
    webview.getSettings().setUserAgentString(userAgent);
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:17,代码来源:WebViewActivity.java

示例3: 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);
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:40,代码来源:AboutActivity.java

示例4: onDestroy

import android.webkit.WebView; //导入方法依赖的package包/类
/** Called when the activity is finally destroyed or in portrait-landscape switch. */
  @Override
  public void onDestroy()	{
// mhistoricalRecMgr.flush();	// shouldn't be done here because onDestroy is not called when switch to home screen and put smartmath background.

  	// release memory of wvOutput.
  	WebView wvOutput = (WebView) findViewById(R.id.webviewSmartMathOutput);
  	if (wvOutput != null)	{
	ViewGroup viewGroup = (ViewGroup) wvOutput.getParent();
	if (viewGroup != null)
	{
		viewGroup.removeView(wvOutput);
	}
	wvOutput.setFocusable(true);
	wvOutput.removeAllViews();
	wvOutput.clearHistory();
	wvOutput.destroy();
  	}
  	if (isFinishing())	{
  		MFPAdapter.clear();
  	}
  	try	{
  		super.onDestroy();
  	} catch(Exception e)	{
  		// have to add this for Amazon because at com.amazon.android.Kiwi.onDestroy(Unknown Source) it may throw exceptions.
  	}
  	if (isFinishing())	{
  		System.exit(0);	// clear memory so that if adView get problem, it can really restart.
  	}
  }
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:31,代码来源:ActivitySmartCalc.java

示例5: 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;
}
 
开发者ID:SOASTA,项目名称:touchtestweb-android,代码行数:50,代码来源:MainActivity.java

示例6: 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

示例7: 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

示例8: 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.setFocusable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。