Code example for Fragment

Methods: getActivity, onCreate, setHasOptionsMenu

0
    private WebView mWebView;
    private View mLoadingSpinner;
 
    @Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setHasOptionsMenu(true);
        AnalyticsUtils.getInstance(getActivity()).trackPageView("/Map");
    } 
 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
 
        ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_webview_with_spinner, null);
 
        // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are 
        // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. 
        root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.FILL_PARENT));