Back to project page Action-Bar-Fragment-Example.
The source code is released under:
Copyright (c) 2012, Feig Dev, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ...
If you think the Android project Action-Bar-Fragment-Example listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.feigdev.fragmentex; //from w w w . j av a2 s .c o m import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentTransaction; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.webkit.WebView; import android.webkit.WebViewClient; public class WebFragment extends Fragment{ int mNum; /** * When creating, retrieve this instance's number from its arguments. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mNum = getArguments() != null ? getArguments().getInt("num") : 1; } public static WebFragment newInstance(int index) { WebFragment f = new WebFragment(); // Supply index input as an argument. Bundle args = new Bundle(); args.putInt("index", index); f.setArguments(args); return f; } /** Called when the activity is first created. */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null){ return null; } View web = inflater.inflate(R.layout.web, container, false); ((WebView)(web.findViewById(R.id.web_login))).getSettings().setJavaScriptEnabled(true); ((WebView)(web.findViewById(R.id.web_login))).setWebViewClient(new HelloWebViewClient()); ((WebView)(web.findViewById(R.id.web_login))).loadUrl("http://www.google.com"); return web; } private class HelloWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } } }